Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Help with my Arrow Fire Script

$
0
0
Hi, im new to c# programing in unity and I have been trying to create a primative arrow fire script but no matter how hard I try I keep get this error after shooting an arrow: NullReferenceException: Object reference not set to an instance of an object Arrow_Fire.Update () (at Assets/Scripts/Arrow_Fire.cs:15) Here is the code too so if you have any suggestions it would help greatly (: using UnityEngine; using System.Collections; public class Arrow_Fire : MonoBehaviour { public Rigidbody arrow; public int speed = 20; void Update () { if (Input.GetButtonDown("Fire1")) { Rigidbody arrowClone = Instantiate(arrow, transform.position, transform.rotation) as Rigidbody; arrowClone.velocity = transform.TransformDirection(new Vector3(0, 0, speed)); } } }

Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>