UnityNinja Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

UnityNinja CommunityLog in

UnityNinja - Video Game Development Community, including Resources, Forums, Marketplace & More.


descriptionEasy Gun Script EmptyEasy 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);
}

}

}
}

descriptionEasy Gun Script EmptyRe: Easy Gun Script

more_horiz
thanks helps alot cheers

descriptionEasy Gun Script EmptyRe: 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!

descriptionEasy Gun Script EmptyRe: Easy Gun Script

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum