Unity3D----行为操作
Unity3D----行为操作
1.导入资源

2.将小人模型放置到摄像机下

3.设置移动
3.1 创建 Animator Controller ---添加到人物模型

3.2 Motion设置说明
英文属性值 中文翻译
HumanoidCrouchTurnLeft 左转
HumanoidCrouchTurnRight 右转
HumanoidCrouchWalk 步行
HumanoidCrouchWalkLeft 向左行走
HumanoidCrouchWalkRight 向右行走
HumanoidCrouchWalkRightB 向右行走B
HumanoidFall 仿人坠落
HumanoidFallLeft 仿人坠落-左
HumanoidFallRight 仿人坠落-右
Humanoidldle
HumanoidldleJumpUp 仿人跳跃
HumanoidJumpForwardLeft 仿人左前跳
HumanoidJumpForwardRight 仿人向右跳跃
HumanoidJumpUp 仿人跳跃
HumanoidMidAir 向上跳跃
HumanoidMidAirLeft 仿人左中
HumanoidMidAirRight 仿人中间右侧
HumanoidRun 仿人跑步
HumanoidRunLeft 仿人向左跑步
HumanoidRunLeftSharp 仿人左锐
HumanoidUnLeftSharp 仿人非左锐
HumanoidRunRight 仿人向右跑步
HumanoidRunRightSharp 仿人右锐
HumanoidUnRightSharp 仿人非右锐
HumanoidWalk 仿人步行
HumanoidWalkLeft 仿人左行走
HumanoidWalkLeftSharp 仿人行走左锐
HumanoidWalkRight 仿人向右行走
HumanoidWalkRightSharp 仿人行走右锐
RobotBoyCrouchingWalk 机器人男孩蹲着走
RobotBoyFalling 机器人男孩坠落
RobotBoyldle
RobotBoyldle公司
RobotBoyJump01 机器人男孩跳跃01
RobotBoyJump02 机器人男孩跳跃02
RobotBoyJump03 机器人男孩跳跃03
RobotBoyJump04 机器人男孩跳跃04
RobotBoyJump05 机器人男孩跳跃05
RobotBoyJump06 机器人男孩跳跃06
RobotBoyJump07 机器人男孩跳跃07
RobotBoyJump08 机器人男孩跳跃08
RobotBoyJump09 机器人男孩跳跃09
RobotBoyJump10 机器人男孩跳跃10
RobotBoyJump11 机器人男孩跳跃11
RobotBoyRun 机器人男孩跑步
RobotBoyWalk 机器人男孩步行
StandHalfTurnLeft 左半转向支架
StandHalfTurnRight 站半右转
StandQuarterTurnLeft 站区左转
StandQuarterTurnRight 看台右转弯

3.3 将待机下的其他操作设置True 其它对应操作为False


3.4 创建脚本Player设置操作绑定按键
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
//定义人物动画
private Animator animator;
void Start()
{
animator = gameObject.GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
//按住W键播放“往前跑”动画
if (Input.GetKey(KeyCode.W))
{
animator.SetBool(name: "RunForward", true);
}
else
{
animator.SetBool(name: "RunForward", false);
}
//按住A键播放“往左跑”动画
if (Input.GetKey(KeyCode.A))
{
animator.SetBool(name: "RunLeft", true);
}
else
{
animator.SetBool(name: "RunLeft", false);
}
//按住D键播放“往右跑”动画
if (Input.GetKey(KeyCode.D))
{
animator.SetBool(name: "RunRight", true);
}
else
{
animator.SetBool(name: "RunRight", false);
}
//按住S键播放“转身”动画
if (Input.GetKey(KeyCode.S))
{
animator.SetBool(name: "TurnLeft", true);
}
else
{
animator.SetBool(name: "TurnLeft", false);
}
//按住S键播放“转身”动画
if (Input.GetKey(KeyCode.F))
{
animator.SetBool(name: "TurnRight", true);
}
else
{
animator.SetBool(name: "TurnRight", false);
}
//按住S键播放“转身”动画
if (Input.GetKey(KeyCode.X))
{
animator.SetBool(name: "JumpUp", true);
}
else
{
animator.SetBool(name: "JumpUp", false);
}
}
}

浙公网安备 33010602011771号