I am trying to create a gameObject that has lifetime, life of the gameObject decreases over time until it dies (deteriorates over time like a real creature), but it will be able to get a more life (time or %). I thought of creating an animation for the lifetime line, the animation will represent the deteriorate process in real time. When the gameObject gets more life, the animation will rewind the deteriorate process back the % or time it gets. I haven't found a simple way of rewinding the animation only some % or time back, and animate the rewinding process for like a one second, not just skipping back. Example: GameObject has an animation for the deterioration process that is 3 minutes long, if it dose not get more life it will only life for 3 minutes (the animation will trigger a function for the death). But if the gameObject has been living for 2 minutes (is has 33% life left) and gets a 1 more minute in life (33% more life), it will rewind the animation of the deterioration process back to 1 minute (now it has 66% life left), and this rewind animation will happen in two seconds (rewinds back 33% or 1 minute of life in two seconds). Any ideas for doing this the simple way will be appreciated!
Hi joihelgi. If you are using an Animator Component (AKA mecanim) you can use Animator.Play() http://docs.unity3d.com/ScriptReference/Animator.Play.html The time is a normalized time which mean that it goes from 0 to 1, it like a percent. If you are using an Animation component(AKA legacy) you can use this: animation["Walk"].normalizedTime http://docs.unity3d.com/ScriptReference/AnimationState-normalizedTime.html Best regards,