Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. public Vector3 MoveAndStopAtPoint(Vector3 StartingPosition, Vector3 Destination, float Speed, float ElapsedTime)
  2. {
  3. Vector3 direction = Destination - StartingPosition;
  4. float distanceSquared = direction.LengthSquared();
  5. if (direction != Vector3.Zero) direction.Normalize();
  6.  
  7. Vector3 movement = direction * Speed * ElapsedTime;
  8. if (movement.LengthSquared() < distanceSquared)
  9. {
  10. return StartingPosition + movement;
  11. }
  12. else
  13. {
  14. return Destination;
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement