I want to generate gun fire whenever i press Space button
I want to generate gun fire , not continuous bust of fire images I want some delay Because gun will take time to load,and when I release that button firing should stop. For this I have used InvokeRepeating function.
if(key Pressed Down)
{
InvokeRepeating("fire",0.001f,0.5f)
}
if(key pressed up)
{
CancelInvoke("fire");
}
I don't know why it is not working. I work sometime but most of the time fire is keep on generating. Thank you so much for helping in advance.
Hi @LA$$anonymous$$SHAY$$anonymous$$AVIA - This has been answered several times (I googled and found this in 5 seconds) - see: https://answers.unity.com/questions/283377/how-to-delay-a-shot.html
Thank you so much . I was searching wrong thing. Thank you .
Thank you with your help I am able to create my second playable game. gamejolt.com/games/ps/368693
Answer by Hsni · Sep 18, 2018 at 11:56 AM
void Update(){ if (Input.GetKeyDown(KeyCode.Space)) { Shoot(); } }
Your answer