- Home /
Reload Script Not Working
This is my gun script. The only part that doesn't work is the reloading part. Every time I press r, it doesn't reload. I am a beginner at Javascript, so I really could use your valuable knowledge. Thanks.
pragma strict
ar shot : GameObject; var shootingObject : GameObject; var ammo : int;
function Start () { ammo = 15; }
function Update () { if(Input.GetButtonDown("Fire1")) { if(ammo > 0) {
ammo --;
var projectile = Instantiate(shot, transform.position, transform.rotation);
projectile.rigidbody.AddForce(transform.forward *6000);
if(Input.GetKey("r") ) {
ammo += 10;
}
}
}
}
Answer by FlyingHighUp · Apr 03, 2014 at 04:33 AM
I'm not a Javascript guy, but try changing "Input.GetKey("r")" to "Input.GetKey(KeyCode.R)"
Your answer
Follow this Question
Related Questions
I have two animations, on the same parent object and how do i make them play at different times. 2 Answers
Shoot script help 1 Answer
Reload Animation Problems 2 Answers
Reset a scene 2 Answers
Gun script Reload not working well 1 Answer