unity官方demo学习之Stealth(二十一)敌人动画设置类

(公有,不属于任何脚本,也不用继承MonoBehaviour,所以也没有Awake函数,获取引用实在构造器
中实现的)

用于敌人动画中参数的设置,其中缓冲参数的作用是让敌人动作转变时更平滑

添加脚本DoneAnimatorSetup

using UnityEngine;
using System.Collections;

public class DoneAnimatorSetup
{
    public float speedDampTime = 0.1f;				// Damping time for the Speed parameter.
	public float angularSpeedDampTime = 0.7f;		// Damping time for the AngularSpeed parameter
	public float angleResponseTime = 0.6f;			// Response time for turning an angle into angularSpeed.
	
	
	private Animator anim;							// Reference to the animator component.
	private DoneHashIDs hash;						// Reference to the HashIDs script.
    
	
	// Constructor
    public DoneAnimatorSetup(Animator animator, DoneHashIDs hashIDs)
    {
        anim = animator;
		hash = hashIDs;
    }
	
	
    public void Setup(float speed, float angle)
    {
		// Angular speed is the number of degrees per second.
        float angularSpeed = angle / angleResponseTime;
        
		// Set the mecanim parameters and apply the appropriate damping to them.
        anim.SetFloat(hash.speedFloat, speed, speedDampTime, Time.deltaTime);
		anim.SetFloat(hash.angularSpeedFloat, angularSpeed, angularSpeedDampTime, Time.deltaTime);
    }	
}
参数(公有)

速度缓冲时间

角速度缓冲时间

把角度转为角速度的反应时间

(私有)

引用Animator组件

应用HashIDs脚本

函数

public AnimatorSetup(Animator animator, HashIDs hashIDs)构造器,初始化

public void Setup(float speed, float angle)

角速度等于 = 角度 / 角度转换时间

设置动画参数 并设置缓冲时间



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值