Animace 2+
This commit is contained in:
@@ -205,6 +205,8 @@ namespace MegaKoop.Game.EditorExtensions
|
||||
|
||||
var move = root.AddState("Move", new Vector3(250, 150, 0));
|
||||
move.motion = CreateMoveBlendTree(controller);
|
||||
move.speedParameterActive = true;
|
||||
move.speedParameter = "MoveSpeedNormalized";
|
||||
|
||||
AnimatorState crouch = null;
|
||||
if (crouchIdle != null)
|
||||
@@ -262,11 +264,27 @@ namespace MegaKoop.Game.EditorExtensions
|
||||
}
|
||||
|
||||
// Jump transitions: AnyState -> Jump Begin
|
||||
var anyToJumpBegin = root.AddAnyStateTransition(jumpBeginState);
|
||||
anyToJumpBegin.hasExitTime = false;
|
||||
anyToJumpBegin.duration = 0.05f;
|
||||
anyToJumpBegin.canTransitionToSelf = false;
|
||||
anyToJumpBegin.AddCondition(AnimatorConditionMode.If, 0f, "Jump");
|
||||
// Jump transitions from grounded states
|
||||
var idleToJump = idle.AddTransition(jumpBeginState);
|
||||
idleToJump.hasExitTime = false;
|
||||
idleToJump.duration = 0.05f;
|
||||
idleToJump.AddCondition(AnimatorConditionMode.If, 0f, "IsJumping");
|
||||
idleToJump.AddCondition(AnimatorConditionMode.IfNot, 0f, "IsGrounded");
|
||||
|
||||
var moveToJump = move.AddTransition(jumpBeginState);
|
||||
moveToJump.hasExitTime = false;
|
||||
moveToJump.duration = 0.05f;
|
||||
moveToJump.AddCondition(AnimatorConditionMode.If, 0f, "IsJumping");
|
||||
moveToJump.AddCondition(AnimatorConditionMode.IfNot, 0f, "IsGrounded");
|
||||
|
||||
if (crouch != null)
|
||||
{
|
||||
var crouchToJump = crouch.AddTransition(jumpBeginState);
|
||||
crouchToJump.hasExitTime = false;
|
||||
crouchToJump.duration = 0.05f;
|
||||
crouchToJump.AddCondition(AnimatorConditionMode.If, 0f, "IsJumping");
|
||||
crouchToJump.AddCondition(AnimatorConditionMode.IfNot, 0f, "IsGrounded");
|
||||
}
|
||||
|
||||
// Jump Begin -> Jump Fall (automatic after animation)
|
||||
var jumpBeginToFall = jumpBeginState.AddTransition(jumpFallState);
|
||||
@@ -330,10 +348,11 @@ namespace MegaKoop.Game.EditorExtensions
|
||||
controller.AddParameter("MoveX", AnimatorControllerParameterType.Float);
|
||||
controller.AddParameter("MoveZ", AnimatorControllerParameterType.Float);
|
||||
controller.AddParameter("Speed", AnimatorControllerParameterType.Float);
|
||||
controller.AddParameter("MoveSpeedNormalized", AnimatorControllerParameterType.Float);
|
||||
controller.AddParameter("IsGrounded", AnimatorControllerParameterType.Bool);
|
||||
controller.AddParameter("IsCrouching", AnimatorControllerParameterType.Bool);
|
||||
controller.AddParameter("IsDead", AnimatorControllerParameterType.Bool);
|
||||
controller.AddParameter("Jump", AnimatorControllerParameterType.Trigger);
|
||||
controller.AddParameter("IsJumping", AnimatorControllerParameterType.Bool);
|
||||
}
|
||||
|
||||
private Motion CreateMoveBlendTree(AnimatorController controller)
|
||||
|
||||
Reference in New Issue
Block a user