Unity3D----行为操作

Unity3D----行为操作

1.导入资源

               

 

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

                 

 

 3.设置移动

  3.1 创建 Animator Controller ---添加到人物模型

    

 

 

   3.2 Motion设置说明

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
英文属性值   中文翻译
     
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设置操作绑定按键

    

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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);
        }
    }
}

 

posted @   打工仔-也想飞  阅读(105)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示