Mar*_*son 0 c# unity-game-engine lerp
我想要调整控制我的动画速度的变量,以便它在混合树中流畅地过渡.
void Idle()
{
_agent.SetDestination(transform.position);
//Something like the following line
_speed = Mathf.Lerp(0.0f, _speed, -0.01f);
_animationController._anim.SetFloat("Speed", _speed);
}
Run Code Online (Sandbox Code Playgroud)
我读过你不能减负,所以我该怎么做?
我觉得你用Lerp很糟糕.
如Unity文档(http://docs.unity3d.com/ScriptReference/Mathf.Lerp.html)中所述,您应该传递3个浮点数,最小值作为第一个参数,最大值作为第二个参数,时间作为第三个参数.
第三个应该是beetwen 0和1.
除此之外,你总是可以在数字之后将数字设为负数.
一些例子 :
如果你想从-10到10,从0到20,然后减去10.
float whatever = Mathf.Lerp(0f,20f,t);
无论如何 - = 10f;
如果你想从0到-50,从0到50,然后使其为负.
float whatever = Mathf.Lerp(0f,50f,t);
无论如何= -whatever;