- Home /
How do I make an object move and have an animation attached at the same time?
Hi guys. I want to make a game where you can control a car and when you press the up key to make the car move the animation is triggered to make parts of the car move (e.g a pedal move down). I have the script to make the car move, but when i add the animation onto a part of the car, that part of the care does the animation attached but stays static. Any ideas how to help? Thank you! :)
It sounds like the car part that has the animation is always going back to a certain position because the animation has those world coordinates saved. Basically it's taking global coordinates, although it's supposed to play the animation at it's current position. I think there's a way to get around that using an empty gameobject.. Could be caused by something else altogether though ;D
Answer by keld-oelykke · Mar 21, 2012 at 07:53 PM
Let the Animation component be on a Game Object 'Parts' that is controlled by animations. Let 'Parts' be a child Game Object of a 'Car' Game Object that you control by code.
The Animation component only modify local transform properties of the skeleton game object hierarchy, so you can modify the transform of 'Car' as a kind of pivot point for the whole car.
Hope it makes sense :)