this Bullet shooting script error
Hey guys , i am trying to make a gun shoot but a error keeps coming up NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs) bullet.FixedUpdate () (at Assets/Scripts/bullet.js:15)
Here's the code
// The speed the bullet moves
var Speed : float = .4;
// The number of seconds before the bullet is automatically destroyed
var SecondsUntilDestroy : float = 10;
private var startTime : float;
function Start () {
startTime = Time.time;
}
function FixedUpdate () {
// Move forward
this.gameObject.transform.position += Speed * this.gameObject.transform.left;
// If the Bullet has existed as long as SecondsUntilDestroy, destroy it
if (Time.time - startTime >= SecondsUntilDestroy) {
Destroy(this.gameObject);
}
}
function OnCollisionEnter(collision : Collision) {
// Remove the Bullet from the world
Destroy(this.gameObject);
}
Well guys please respond asap. I dont know what's wrong.
Comment
Your answer
Follow this Question
Related Questions
Test if a bullet will hit before shooting it? 2 Answers
How to make a bullet in a top down arcade-styled game? 0 Answers
Bullet does not move forward 0 Answers
Bullet Destroy 1 Answer
How can I create Raycast bullet innaccuracy as a cone? 2 Answers