Unity Mathf

1、Lerp 线性移动

float startTime = 1f;//动画持续的时间为1秒
//start开始状态
//end结束状态
//startTime为持续的时间
float current = Mathf.Lerp/LerpAngle(start, end, Time.time - startTime)

使用方法

public void Update() {
    transform.position = new Vecter3(Mathf.Lerp(start,end,Time.time - startTime),...y,...z);
}

2、LerpAngle

使用方法

public void Update() {
    transform.eulerAngles = new Vecter3(...x,current , ...z);
}

3、MoveTowards

匀速运动

public void Update() {
    //speed速度
    transform.eulerAngles = new Vecter3(...x,Mathf.MoveTowards(satrt,end,speed) , ...z);
}


你可能感兴趣的:(Unity Mathf)