A, building plane, a new state machine, a new code player, drag character models, facing the Z axis direction is
Two, double-click the state machine, and dragged WAIT00 animation into the state machine, realize people waiting for action,
Animation Animation level the Layers: if a character to play mobile shooting action, and action is the need to separate, so you need to use different Animation layer to control the movements of different body parts,
Weight: the Weight, the current animation level the influence degree of the play the role of animation,
Mask, Mask, to block out the part of the body animations,
Sync: synchronous,
Timing: time configuration,
IK Pass: reverse kinematics transmission,
Animation Animation Parameters Parameters: Animation Parameters is a series of variables defined in the Animation system, can also be accessed through script and assignment,
The parameter value of four types:
Float: floating-point
Int: integer
Bool: returns a Boolean value, through the check box to select true or flase
Trigger: Trigger a Boolean value, reset controller consume a shift, said by a round button
state of Animation Animation States the Animation in the state machine (point) :
Motion: under the current state of cartoon
Speed: the default Speed
Normalized Time: the end of the animation playback for
Mirror, Mirror switch, only effective for human animation,
Cycle Offset: Offset,
Foot IK: whether using inverse kinematics for Foot, only effective for human animation,
Write Defaults: animation state is written back to the default, animation termination will cover the starting state,
Transitions: starting from the current state of the transition condition list,
Three, drag WAIT01, WAIT02 WAIT03, WAIT04, press the number 1 play WAIT01, press the number 2 play WAIT02 press the number 3 play WAIT03, press number four play WAIT04,
If (Input. GetKeyDown (" 1 "))
{
Anim. Play (" WAIT01 ", 1, 0 f);
}
If (Input. GetKeyDown (" 2 "))
{
Anim. Play (" WAIT02 ", 1, 0 f);
}
If (Input. GetKeyDown (" 3 "))
{
Anim. Play (" WAIT03 ", 1, 0 f);
}
If (Input. GetKeyDown (" 4 "))
{
Anim. Play (" WAIT04 ", 1, 0 f);
}
about Animation transition Animation Transitions point (arrow) : animated transition refers to the transition from an Animation state to another state of Animation, select the state machine when the arrow)
Animation transition not only defines the state between the mixed need how long, and defines under what conditions they should be activated, only when certain conditions are true, to set the conversion,
Add two arrows represent two transition conditions, each transition condition is or the relationship between the two conditions satisfy a, can realize the conversion, but each parameter is in the transitional condition and relationship, must meet all at the same time, the animation can transition,
From the Exit Time: whether to enable Exit Time, enabled, the current animation broadcast can enter into the next animation,
Setting: set over time, offset, such as
The Conditions: when animation parameters conform to the corresponding Conditions, trigger the animation transition, (key of animation and scripting interaction)
Four, building mixed tree walk, run, the realization of people walking around running jump, and can control the offset,
1. New parameters inputH inputV (Float type); Run, jump (bool),
2. Double-click the mixed tree run, mixed type of 1 d, by only one parameter to control the mixture of animation,
- 1 to shift to the left, 0 to run forward, 1 to shift to the right, the graphics and no other parts overlap;
- 1 to 0, a coincidence of dark triangle, here according to the weight mixing run forward and run to the left of animation,
3. Double-click the mixed tree walk, mixed type of 2 d Simple Directional, through two parameters to control,
4. Select the arrows in the base layer to set the transition condition
5. Increase jump:
using System.Collections;
Using System. Collections. Generic;
Using UnityEngine;
Public class player: MonoBehaviour
{
Private Animator anim.
Private Rigidbody rbody;
Private float inputH;
Private float inputV;
Private bool run;
Void the Start ()
{
Anim=GetComponent(a);
Rbody=GetComponent(a);
The run=false;
}
Void the Update ()
{
If (Input. GetKeyDown (" 1 "))
{
Anim. Play (" WAIT01 ", 1, 0 f);
}
If (Input. GetKeyDown (" 2 "))
{
Anim. Play (" WAIT02 ", 1, 0 f);
}
If (Input. GetKeyDown (" 3 "))
{
Anim. Play (" WAIT03 ", 1, 0 f);
}
If (Input. GetKeyDown (" 4 "))
{
Anim. Play (" WAIT04 ", 1, 0 f);
}
If (Input. GetKey (KeyCode. LeftShift))
{
The run=true;
}
The else
{
The run=false;
}
If (Input. GetKey (KeyCode. Space))
{
Anim. SetBool (" jump ", true);
}
The else
{
Anim. SetBool (" jump ", false);
}
InputH=Input. GetAxis (" Horizontal ");
InputV=Input. GetAxis (" Vertical ");
Anim. SetFloat (" inputH inputH);
Anim. SetFloat (" inputV inputV);
Anim. SetBool (" run, run).
Float moveX=inputH 20 f * * Time. The deltaTime;//X the speed of the
Float moveZ=inputV 50 f * * Time deltaTime;
If (moveZ & lt;=0 f)
{
MoveX=0 f;
}
Else if (run)
{
MoveX *=3 f;
MoveZ *=3 f;
}
Rbody. Velocity=new Vector3 (moveX, 0 f, moveZ);
}
nullnullnullnullnullnullnull