x


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! :)

more ▼

asked Mar 20 '12 at 06:49 PM

lemdi gravatar image

lemdi
3 3 5 7

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

Mar 20 '12 at 09:26 PM merry_christmas
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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 :)

more ▼

answered Mar 21 '12 at 07:53 PM

keld-oelykke gravatar image

keld-oelykke
346 1 2 5

Thank you it works now :)

Mar 21 '12 at 08:09 PM lemdi
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3807
x1372
x418
x278

asked: Mar 20 '12 at 06:49 PM

Seen: 471 times

Last Updated: Mar 21 '12 at 08:09 PM