FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.

Share

descriptionEasy Gun Script

more_horiz
Just attach this to the gun

using UnityEngine;
using System.Collections;

public class Instatinate : MonoBehaviour {

// Use this for initialization
public Rigidbody bullet;
public Transform emptygameobject;
public float distance;
public GameObject enemy;

void Start () {

}

// Update is called once per frame

void Update () {
if (Input.GetButtonDown ("Fire1")) {

Rigidbody rocketInstance;
rocketInstance = Instantiate(bullet, emptygameobject.position, emptygameobject.rotation)as Rigidbody;
rocketInstance.AddForce(emptygameobject.forward * 5000);


}
}
void myRaycast(){
RaycastHit hit;
Ray myRay = new Ray(transform.position, Vector3.forward);
if(Physics.Raycast (myRay, out hit, distance)){
if(hit.collider.tag == "enemy"){
Destroy(enemy);
}

}

}
}

descriptionRe: Easy Gun Script

more_horiz
thanks helps alot cheers

descriptionRe: Easy Gun Script

more_horiz
ummm so i want to use this but im not sure if i need to get a bullet asset since im new so please help me!
Permissions in this forum:
You cannot reply to topics in this forum