Unity入门操作_混合树_033
2017-09-01 17:39
483 查看
混合树出现可以解决曲线运动时动画的改变:
首先我们先导入资源
如图所示默认是Run动画,此时运行我们可以看到下图,
如图所示我们需要把Apply Root Motion取消勾选,现象如下图
双击Controller进入下图
此时我们创建一个如下图所示
创建成功后会自动生成一个下图
双击所建立的
进入下图(注意此时进入了Blend Tree层)
我们点击它并为他修改模式
添加Motion
添加完成后如下图
此时我们需要将Automate Threshold取消勾选才能对其初始数值进行修改
此时我们对混合树的操作就告一段落了,我们就可以返回上一层并对动画执行流程进行修改,操作如下:
操作完成后我们就可以写脚本用按键实现前进时不同的动画了,
脚本如下
using UnityEngine;
using System.Collections;
public class playtest : MonoBehaviour {
}
首先我们先导入资源
如图所示默认是Run动画,此时运行我们可以看到下图,
如图所示我们需要把Apply Root Motion取消勾选,现象如下图
双击Controller进入下图
此时我们创建一个如下图所示
创建成功后会自动生成一个下图
双击所建立的
进入下图(注意此时进入了Blend Tree层)
我们点击它并为他修改模式
添加Motion
添加完成后如下图
此时我们需要将Automate Threshold取消勾选才能对其初始数值进行修改
此时我们对混合树的操作就告一段落了,我们就可以返回上一层并对动画执行流程进行修改,操作如下:
操作完成后我们就可以写脚本用按键实现前进时不同的动画了,
脚本如下
using UnityEngine;
using System.Collections;
public class playtest : MonoBehaviour {
private Animator anim; private float horizontal; private float vertical; public float speed; public float rotateSpeed; // Use this for initialization void Start () { anim = GetComponent<Animator>(); } // Update is called once per frame void Update () { horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical"); if (Input.GetKey(KeyCode.W)||Input.GetKey(KeyCode.UpArrow)) { anim.SetBool("run", true);transform.Translate(Vector3.forward*Time.deltaTime*speed,Space.Self); if (vertical!=0) { anim.SetFloat("RunValue",horizontal); transform.Translate(Vector3.forward * Time.deltaTime * speed*Mathf.Abs(horizontal), Space.Self); transform.Rotate(Vector3.up * rotateSpeed * Time.deltaTime * horizontal); } } if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.UpArrow)) { anim.SetBool("run", false); } }
}
相关文章推荐
- Unity_Lua_VS环境下入门操作
- Unity入门操作_关节,布料_017
- Unity入门操作_025_01
- Unity入门操作_音频_035
- Unity入门操作_Time类_004
- 【浅墨Unity3D Shader编程】之五 圣诞夜篇: Unity中Shader的三种形态对比&混合操作合辑
- Unity入门操作_PlayerPrefs存储_037
- 【浅墨Unity3D Shader编程】之五 圣诞夜篇: Unity中Shader的三种形态对比&混合操作合辑
- Unity入门操作_UGUI_Button理论_025
- Unity入门操作_UGUI_ScrollBar_029
- Unity入门操作_粒子系统_034
- Unity 之 Shader Blend 混合操作 - 八
- Unity入门操作_积木_009
- Unity入门操作_线性,球形检测_014
- Unity入门操作_UGUI_InputFie_026
- Unity入门操作_UGUI_事件_030
- Unity入门操作_ 摄影机_019
- Unity入门操作_动画系统_Mecanim_032
- Unity入门操作_ 角色控制器_015
- Unity入门操作_动画系统_Legacy_031