The problem is quite simple. I have an FBX model of a gun, with animations. To be more specific, the model (named WEAPON1), has two child parts. The body (called Arm), and the cannon (Called AXIS_CANNON, which is the animated part). To import the animations, I do the following:
- First, I import the FBX into the project explorer by dragging it inside.
- I select the imported model, and in the inspector, I create 4 animations, like this:
http://i.imgur.com/4A66TyH.jpg
-
Now, I drag the weapon model inside the scene.
-
I create a new C# script, called “WeaponController.cs”. Adding the following lines:
private int power; // Use this for initialization void Start () { power = 0; animation.Play("FIRING"); }
I attach it to my WEAPON1 entity. Then, I add the animations trough the inspector, like this:
http://i.imgur.com/F7pO1DH.jpg
I start the game, but nothing happens. No animation plays. I tried a lot of things like, for example, getting the object:
GetComponent("WEAPON1").animation.Play("FIRING");
Or passing the WEAPON1 entity trough the inspector:
public GameObject Weapon;
private int power;
// Use this for initialization
void Start () {
power = 0;
Weapon.animation.Play("FIRING");
}
With no luck. So my last chance is that you point me what am I doing wrong…
The only clue is that the console give me a few warnings telling me that I should mark my animations as ‘Legacy’, but I have no clue on how to do that.
Thanks in advace!
Yeh, seems like setting my animations as Legacy was my problem. Your answer helped me and the problem is solved. Many thanks!
– GMagnus