Been trying to find an answer for this for a while and im currently having a brain freeze.
I have a model which has 5 frames of animation. frame 1 its fine, frame 2 dented, frame 3 more dented, frame 4 more damaged and frame 5 crushed.
I've also created a health var for it.
What i want is when that health drops to under 80 the model changes to frame 2. If the health drops under 60 the model changes again to the next frame and so forth.
Does anybody know how to do it please?
I do apologies if im being thick. But its driving me slowly mad. If it helps i do own Unity Pro.
Thank you in advance.
asked May 27 '10 at 07:40 PM
The way I would do it is break up the animation into separate animation clips and name them accordingly. I'd set their wrap mode to clamp forever as well.
Then you make sure your model's game object has an animation component attached to it and it has reference to the aforementioned animation clips.
From there it is simply a matter of implementing a conditional statement in your script where you accumulate your damage.
Note: You might have to adapt this to suit your Game Object structure, as I am operating under the assumption that the script in which you accumulate damage is a component of the same Game Object that your animation component is attached to.
Notice in my script I am working backwards, this is because if you did it the other way( if(health < 90) ) it will return true on that case for everything less than 90 and you wont see the state change because your logic is flawed.
Just a note that there are FAR more efficient ways to do this but I am working here for the sake of simplicity.
Hope that helps.
answered May 27 '10 at 11:31 PM