Ok, this is frustrating but Ive created an animation loop on a prefab however after the prefab is spawned the animation (which is changes in position/rotation) runs the animation (thus moving the prefab) far away from where the prefab is spawned.
For example if my prefab is spawned at the origin, because of where I placed the prefab when I animated it, it animates in THAT place.
I need my prefab to run the animation but in the PLACE where it was spawned, not where I animated the original prefab. How can I fix this? What am I doing wrong?
I animated using Unity's animator.
This is an common mistake in unity animation.
It's the case when you have to animate the position and at the same time change the position from the code.
In this case the simplest workaround would be to move your visuals to a child game object and animate the position of that object. Now you can change the position of the (parent) game object from code and still have the additive-like animation on the (child) game object.
Uncheck "Apply Root Motion" in the animator. This will prevent the animator from moving the object. The object will then move using only your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With