duck

Untitled

Jan 29th, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. private Vector3 nowPos;
  2. private Vector3 tarPos;
  3. private float smoothMoveT = 1.0f;
  4. public float smoothMoveSpeed = 1.0f;
  5. public float smoothMoveDuration = 0.3f;
  6.  
  7. public void smooth(Vector3 newTarPos)
  8. {
  9.   nowPos = transform.position;
  10.   tarPos = newTarPos;
  11.   smoothMoveT = 0.0f;
  12. }
  13.  
  14. void Update()
  15. {
  16.   if (smoothMoveT < 1.0f)
  17.   {
  18.     smoothMoveT += ((smoothMoveSpeed*Time.timeScale)/smoothMoveDuration) * Time.deltaTime;
  19.     transform.position = Vector3.Lerp(nowPos, tarPos, smoothMoveT);
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment