Skip to content

Instantly share code, notes, and snippets.

@nopitech
Last active October 30, 2017 13:08
Show Gist options
  • Save nopitech/cec11f86f9e8321073cff9bba0955da7 to your computer and use it in GitHub Desktop.
Save nopitech/cec11f86f9e8321073cff9bba0955da7 to your computer and use it in GitHub Desktop.
Mathf.SmoothDamp
public class TestScript : MonoBehaviour
{
public Vector3 target;
public float smoothTime = 1f;
public float yVelocity = 0.0f;
void Start()
{
}
void Update()
{
// 値をスムーズに
float newPosition = Mathf.SmoothDamp(transform.position.y,
target.y,
ref yVelocity,
smoothTime);
// 適用
transform.position = new Vector3(transform.position.x,
newPosition,
transform.position.z);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment