Prefab animation problem

Hi everyone !

I’m not sure if it’s the right place to ask my question (I hesitated with a Maya forum), but I’ll try …

I have a problem with a prefab made with a maya model. When I try to instantiate it in a specific position and animate it, it moves instantly to origin and play the animation. But if I delete the animation line, the game object stays where it should be.
I don’t have this problem with an other prefab. The code is the same, only the maya model is different. I have a skeleton in the second model, contrary t the first one, I don’t know if it’s the problem …

You should make an empty game object that should be parent of your made and animated object. This empty game object must have all scripts that is made to your game object.

To run an animation of your game object you have to make a variable that is type of GameObject and would be your game object. use this (javascript):

var myObject : GameObject; //your game object that has animation

var myAnimation : String; //your animation name

//when you want to run animation do this:

myObject.animation.Play(myAnimation);

this is working even when you are changing the transform of the empty game object.

You should make an empty game object that should be parent of your made and animated object. This empty game object must have all scripts that is made to your game object.

To run an animation of your game object you have to make a variable that is type of GameObject and would be your game object. use this (javascript):

var myObject : GameObject; //your game object that has animation

var myAnimation : String; //your animation name

//when you want to run animation do this:

myObject.animation.

I found my problem : the issue was the skeleton !
I added one joint (yes, only one, very useful …) to my model, moved the animation from my geometry to my joint and here it works !
An other problem now is that I need to attach a box collider to my prefabs, and if there is at least a joint, the box collider does not follow the animation. I don’t know why, and for the moment and in my game this is not important.
If someone has an idea why there are these weird problems, let me know :slight_smile: