I have a recoil animation on my machine gun which I have animated inside unity, I have wrote a script which plays the animation when the LMB is clicked, but what I want is that if the LMB is held down it fires the recoil animation 30 times and then stops. How would I do this?
asked Nov 07, 2011 at 08:26 PM
Well this is a very logical problem that involves many aspects of implementation. For a start, you need to create a timing cycle, that only fires the animation when the animation lenght has passed.
So you create a variable and assign it the
and then in the condition, you add
in the condition, to basically only shoot again if the animation length has passed since the last shoot. And then of course you set your 'mylastshoot' variable to Time.time again.
Additionally, since you need to only shoot 30 times, you create a counter variable 'shotsleft' and assign 30 to it.
and modify the condition again,
And then of course you decrease shotsleft after you play the shoot animation.
answered Nov 08, 2011 at 06:28 AM
The Arc Games