该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
1.创建一个gameObject并添加rigibody
2.在动画组件上挂载AniSpeed脚本
脚本为:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AniSpeed : MonoBehaviour {
public float smooth = 50.0f;
private Rigidbody rigidbody;
public GameObject cube;
private float Cube_Speed;
private Animator m_ani;
AnimatorStateInfo animatorInfo;
public float m_Speed = 1f;
void Start () {
rigidbody = cube.gameObject.transform.GetComponent();
m_ani = GetComponent();
}
private void Update() {
float speed = rigidbody.velocity.magnitude;
if (speed == 0f)
{
m_ani.speed = 0f;
}
if (speed != 0f /*&& speed > 2.8f*/)
{
m_ani.speed = speed;
m_ani.speed -= m_ani.speed;
Debug.LogError("当前动画播放速度为:" + speed);
}
//AniSpeeed();
}
public void AniSpeeed()
{
}
}