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));
}
}
}