|
how would I change this script so that if the LMB is held down it loops the animation until it has stopped being held but if pressed once it plays the animation once? function Update () { if(Input.GetButtonDown("Fire1")){ animation.Play("shoot"); } }
(comments are locked)
|
|
Alternatively, there's a simpler approach. Which is how you usually logically implement this kind of functionality. im having problems getting it to work, I have no errors in the console
Nov 10 '11 at 04:12 PM
Dreave
this comment '//boolean value. declare it to false' actually meant that you need to declare the variable to be able to use it! 'var myanimationisplaying : bool;' and then set it to 'false' on start.
Nov 13 '11 at 09:32 AM
The Arc Games
(comments are locked)
|
|
You could change the WrapMode depending on the LBM being pressed. Something in the vicinity of: function Update() This will cause the animation to loop if the button is being held, and to stop looping when the button is not being held. Keep in mind when you release the mouse button, animation will not immediately stop, it will rather reach to the end and then stop. This script dosent seem to do anything, I have checked the console for errors but theres nothing to blame in there, any ideas?
Nov 09 '11 at 06:12 PM
Dreave
It was meant as a guide rather than as a code. The idea is that you change the WrapMode of your AnimationState depending on the user pressing or releasing the LMB: If the user is pressing the LMB, animation should be set to Loop. If the user is not pressing the LMB, animation should be set to Once. Animation start doesn't require anything special in coding, except to make sure you don't re-execute the Play() command while the animation is already playing.
Nov 09 '11 at 07:52 PM
Jehos
(comments are locked)
|
