- Home /
FPS shooting help?
Here's my shooting script.
var Bullet : Transform;
function Update () { if(Input.GetButtonDown("Fire1")) { Instantiate(Bullet,transform.position,Quaternion.identity);
Bullet.rigidbody.AddForce(transform.forward * 1000);
}
}
OK, so, it is a rigidbody, there are no error messages about the script itself, but it is send me a message like this: UnassignedReferenceException: The variable Bullet of 'NewBehaviourScript 1' has not been assigned. You probably need to assign the Bullet variable of the NewBehaviourScript 1 script in the inspector.
How do I assign the variable? Thanks.
Answer by Jason B · Feb 04, 2011 at 01:10 AM
Assign the variable in the inspector, as it says. Click on the object with the script attached, and in the script's component, plug in the value.
Problem is, once you do that, the bullet only fires straight once. Then, just fires from a weird angle and sometimes makes you jump around in the air.
Answer by RyanZimmerman87 · Feb 14, 2013 at 04:40 AM
Zola390 sounds like you need to ignore collision between the bullet and the object shooting it.
For Example:
Physics.IgnoreCollision(instantiateBullet.collider, player.collider);
just plug in your own bullet object, and player object variables.
Your answer
Follow this Question
Related Questions
How do you get a good grip on Unity? 1 Answer
Only trigger when in specific animation 2 Answers
shooting and hit script JS 1 Answer
shooting somthig 3 Answers
Shoot script help 1 Answer