Relative animation?

Hi,

I have two objects with the same animation in different places.

My first animation works flawlessly. When I press down the button it runs its animation.

However, the second button, a few meters away, moves to the first objects location when I press down the button.

This is because the animation data is written in an absolute format. When I scrub the animation in the far away object, it moves to the first object's position.

How can I make the animations relative to their current location?

Thanks

Finally!

I had to put the object inside another GameObject (parent). Then I moved with GameObject instead of the Button.

  • Peter

I can't make this work... I create an empty gameobject, put a cloud as a child, animate the gameobject. Cloud moves ok. I then tried everything to export a package reimport in Unity3d Iphone. Animation comes accross ok. But impossible to make my clouds move relative to their current position. Can you give me more details of what I need to save in the package?

Can someone describe the procedure to do this? I have a hard time getting this to work. Thanks!

Hello everyone. I have the same problem, and the easiest way that i have found to solve it is to create a new group in your 3D software. I mean, if you have an animated box, rotating and moving across the x,y,z axis, make a new group with it before export. Then you will have your mesh with the desired animation and a new node without keys to transport it.

I think I’ve got a relatively painless solution.

My game takes place around a planet and it’s 2.5D so I’m really only concerned with X & Y, though this can easily be adapted to Z as well. So my X is actually my heading around the planet and my Y is my distance from the center of the planet.

I’m currently working with proxy objects that are actually being animated the way I want in a pure 2D context. Making a bunch of animated to take place around an orbit would make my head explode. My GameObject movement class gets a reference to the Transform of the GO that is actually be animated.

In my class, I have class variables that have recording of the lastX and lastY values. These allow me to assess how much the actual animation has changed between frames. In my Step()/Update() method, my logic looks like this:

if( animatedRefTransform != null ) {
		float currentX = animatedRefTransform.position.x;
		float diffX = (currentX - lastX);
		lastX = currentX;
		
		float currentY = animatedRefTransform.position.y;
		float diffY = currentY - lastY;
		lastY = currentY;
}

Then I simply apply the diffX and diffY to my orbiting game object and it gives me what I need, the distance the object has moved on the two axes that I care about.

One last thing to note, make sure in your Start function you store the initial values for lastX and lastY, otherwise you’ll be offset by the positions of wherever your proxy object is animating, :).