public Transform target;
public float smoothTime = 1f;
private Vector3 velocity;
void Update()
{
//Set the position
transform.position
= new Vector3(
Mathf.SmoothDamp(transform.position.x, target.position.x, ref velocity.x, smoothTime),
Mathf.SmoothDamp(transform.position.y, target.position.y, ref velocity.y, smoothTime),
Mathf.SmoothDamp(transform.position.z, target.position.z, ref velocity.z, smoothTime)
);
}
// float result=Mathf.MoveTorwards(float current,float target,float delta);
float delta=10f;
void FixedUpdate()
{
float result=Mathf.MoveTorwards(current,target,Time.fixedDeltaTime*delta);
}
//如汽車動力的提升
//float result=Mathf.Lerp(float current,float target,float percent)
void FixedUpdate()
{
float result=Mathf.Lerp(float current,float target,float percent)
}
//如汽車油門的輸入,離合的輸入。percent爲百分比範圍=[0,1]
//如0--100,percent=0.1,則result=target=10