- Home /
Question by
Demetri_CO · Jan 28, 2013 at 07:49 PM ·
errorphysicstutorial
Lynda Tutroial projectile error
Ok so im doing the lynda tutorial for unity using unity 4 and in the tut she tells me to make this code
#pragma strict
var projectile : GameObject;
var fireRate : float = 0.5;
internal var nextFire : float;
var speed : float = 5;
function Start () {
}
function Update () {
// fire1 is left mouse or left control
if (Input.GetButton ("Fire1") && Time.time > nextFire) {
nextFire = Time.time + fireRate;
var clone : GameObject = Instantiate (projectile, transform.position, transform.rotation);
}
clone.rigidbody.velocity = transform.TransformDirection(Vector3(0,0,speed));
Physics.IgnoreCollision(clone.collider, transform.root.collider);
}
but when i run the game i get this error: NullReferenceException: Object reference not set to an instance of an object Projectile.Update () (at Assets/GameScripts/Projectile.js:28)
line 28 is this line:
Physics.IgnoreCollision(clone.collider, transform.root.collider);
What can i do to fix this error?
Comment
Your answer