Last active
October 30, 2017 13:08
-
-
Save nopitech/cec11f86f9e8321073cff9bba0955da7 to your computer and use it in GitHub Desktop.
Mathf.SmoothDamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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