- Home /
How to change motion/animation in Animator with C# script?
Hi everyone.
I'm currently making a shop for my game app, and I am now making it possible to select other color dragons.
Here is a small part of the code:
} else if (dragon01Unlocked) {
currentSelectedDragon = 1;
Debug.Log ("You selected: " + gameObject.name + " as your fellow dragon!");
}
So in this part we change the 'currentSelectedDragon' integer to the number 1.
In the function update, I now have the following:
if (currentSelectedDragon == 1) {
dragonAnimator..... What now?
}
When the currentSelectedDragon changes, the animation clip in the Animator should also change.
See here:
I want to change the blueGreenDragon 'motion' animation in the Inspector to change to an other animation. How can you do this with code?
To specify the animation it should change to, we can use two ways:
Using variables saying for example:
Animation purpleDragon; Animation yellowDragon; // etc... etc...
Using Resources.Load option in Unity
Would be happy to get some help from you guys!
Thanks in advance, Nathan
Your answer
Follow this Question
Related Questions
Animation created via script does not play 1 Answer
Why i can't play animation clip i did ? Tried anything so far. 1 Answer
How to reset animator controller ? 4 Answers
cutout animation in top down view 2d 1 Answer
How to turn on lights one after the other,How to turn on lights one after the other? 2 Answers