Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » FREE Project Downloads & Recources » Complete Projects » Easy Gun Script

Easy Gun Script

Go down  Message [Page 1 of 1]

1 Easy Gun Script on Wed Aug 06, 2014 10:28 am

Ninjaboy follower

Member [Lv. 3]
Member [Lv. 3]
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"){



View user profile

2 Re: Easy Gun Script on Mon Feb 02, 2015 8:26 pm


Member [Lv. 1]
Member [Lv. 1]
thanks helps alot cheers

View user profile

3 Re: Easy Gun Script on Thu Feb 05, 2015 4:40 am


Member [Lv. 1]
Member [Lv. 1]
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!

View user profile

Sponsored content

Back to top  Message [Page 1 of 1]

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