- Home /
Question by
jimmyismike · Aug 27, 2011 at 10:54 AM ·
shootreloadreloading
Shoot Script Reload Help
Hey I need help with reload. I want it so after you press the reload button (r) you can't immediately shoot after that. I'd also like it so the amount of time after you press r till you can shoot again to be a variable. Now I don't want you to give me a straight up script, I'd like if you could step by step teach me how to do this. Here shoot script,
var prefabBullet:Transform;
var shootForce:float;
var shots : int = 0;
var maxShots : int = 30;
var shootSound : AudioClip;
function Update()
{
if(Input.GetMouseButtonUp(0) && shots < maxShots)
{
var instanceBullet = Instantiate(prefabBullet, transform.position, Quaternion.identity);
instanceBullet.rigidbody.AddForce(transform.forward * shootForce);
audio.PlayOneShot(shootSound);
shots++;
}
else if (shots <= maxShots && Input.GetKeyDown(KeyCode.R))
{
shots = 0;
}
}
Comment
Best Answer
Answer by henry96 · Aug 27, 2011 at 02:01 PM
when u press r (if shots equal 0), make another function for that. Then use yield WaitForSeconds ( ), then make shots equal maxShots.
Your answer
Follow this Question
Related Questions
Wrote a script for Shooting, reloading and to display the AMMO in a GUIText 1 Answer
Shooting and reloading mechanism problem. 1 Answer
No Reload Script Works 1 Answer
reload help 0 Answers
Shoot script help 1 Answer