Hello there,
I’m running into an issue with setting the speed of an additive animation. Each of the vehicles use a number of different additive animations which are modulated by our physics implementation. We have additive animations for each wheel and for each physical component such as:
- RPM - modulated by setting speed (+1 is 1 RPM forwards, -1 is 1RPM backwards. Can get set to any value theoretically). Sets speed property on the AnimationState, wrapmode is set to loop and “loop” is set to true.
- Suspension - modulated from 0-1, sets normalized time property on the AnimationState, wrampode set to clampforever and “loop” is set to false
- Steering - modulated from -1 to +1, sets normalized time property on the AnimationState, wrapmode is set to clampforever and “loop” is set to false
This approach has worked for us when applied to vehicles with four wheels. However, once we extended it to vehicles with six wheels the middle wheel’s rotation animation speed became uncontrollable. Once the animation’s speed is set, its playback speed will modulate from some arbitrary value to another.
What this looks like is that as the vehicle is travelling, the four other wheels (both front and both rear) rotate at the correct speed whereas the middle speeds start at a stop, increase speed, stop, and begin reversing; repeating the pattern forever. This uncontrolled playback continues even after the vehicle has stopped and all speeds for the animations have been set to 0.
While debugging I’ve looked at the values for each of the animation states both before and after the speed is set and have validated that the values exactly match those being sent by our physics layer and that our physics layer is producing the correct values.
I have also validated that each of the animations run individually by using the gameObject.SampleAnimation() method as described in Unity Docs along with a custom editor which I’ve written.
This behaviour with our additive animations isn’t confined to just the mid-wheels spinning however, this is the most clear cut case which I can explain. I’ve exhausted all of my debugging knowledge and am looking to the community to help, please!
Thanks!
Gerald