- Home /
My bullets wont work when i shoot them
I am making a shooting script which mostly works except one thing when i shoot the bullet dissapears and i try viewing it in #scene mode and it is behind me or under the map and i dont know why! i am very new to scripting and would apreciate any help you can provide!
Here is my script:
var Spawn : Transform;
var Bullet : Rigidbody;
var BulletSpeed : float = 1000;
function Start () {
}
function Update () {
if(Input.GetButtonDown("Fire1")){
Fire();
}
}
function Fire(){
var bullet1 : Rigidbody = Instantiate(Bullet,Spawn.position,Spawn.rotation);
bullet1.AddForce(Transform.Forward *BulletSpeed);
}
}
Comment
var Spawn : Transform;
var bullet1 : Rigidbody = Instantiate(Bullet,Spawn.position,Spawn.rotation);
Do you snap something in, in the Inspector? This 'Spawn' is the transform of what exactly?
Your answer
Follow this Question
Related Questions
cant get my gun to work 0 Answers
bullets wont show up 1 Answer
3rd Person Gun Aim 1 Answer
Unity Coroutine problem 1 Answer
Zombie FPS 2 Answers