Mathf.SmoothStep 平滑插值

static function SmoothStep (from : float, to : float, t : float) : float

Description描述

Interpolates between min and max and eases in and out at the limits.

和lerp类似,在最小和最大值之间的插值,并在限制处渐入渐出。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public float minimum = 10.0F;
	public float maximum = 20.0F;
	void Update() {
		transform.position = new Vector3(Mathf.SmoothStep(minimum, maximum, Time.time), 0, 0);
	}
}
var minimum = 10.0;
var maximum = 20.0;

function Update() {
	transform.position = Vector3(Mathf.SmoothStep(minimum, maximum, Time.time), 0, 0);
}
Page last updated: 2011-2-23