NAV16AP
3. jakso lukuvuonna 2016-2017
Now we’re
going to create two animations in 3DS Max for the same character and import
those to Unity.
First start
by creating and animating your character in 3DS Max. Create two animations for
the character: idle & walking. Do these animations in the same timeline.
After you have finished the first animation start animating the second after
that in the timeline.
When you
are finished export the model as fbx to Unity. Select your model and go to rig
tab in inspector. Select legacy as the animation type.
In unity
drag your character to the scene. Open the animation window when your character
is selected. This shows all movement in the same animation. Next to the
animation name it says read only. This means you can’t make changes to that
animation so both idle & walk will play after another.
To get two
different animations you can switch, you need to slice the full animation.
Select the frames you want to include in the new animation and press ctrl + c.
This will copy the frames.
Then create new animation by clicking with the right
mouse button in the project folder choosing create -> animation.
Click the
animation so that it’s active and go to the animation window. Press ctrl + v to
paste the frames to the new animation.
Do the same
thing for the second animation so that you have two separate animations.
To use
these animations in a character you need to create animator for the character
if there isn’t one already. Create animation inside the character inspector as well as in project folder. Remember to choose the controller you have created in the inspector.
After that open the animator window.
Create two
states named idle & walk. Select correct motion for each state and do
transitions between them.
Create a
Boolean parameter called move.
Now you can add walking condition in the idle
state. Remember to use bool true for it. Do the same for the walking animation
but choose bool false this time.
Now the
character has two animations only thing left is to activate those in proper
FSMs. Create FSM for the character that controls the animations. You need to
have installed Playmaker for this.
In the start state use action get key down 4
times. Create event called move and use W, A, S and D as key on the get key
down action and event walk_animation in the send event section. Create set animator bool
action and your move parameter in it.
Then create
a new state. In this state use action get key up 4 times. Use same buttons and
in event section use finished as transition. Create set animator bool action
and choose again the move parameter. Put checkmark in the value section so that
it will be true when player presses any of the movement keys.
Now you can
test your animation in the game window. When no key is pressed the idle animation should be
playing. When any of the WASD keys is pressed it should change the animation to
walking.
Ei kommentteja:
Lähetä kommentti