Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Vector3 MoveAndStopAtPoint(Vector3 StartingPosition, Vector3 Destination, float Speed, float ElapsedTime)
- {
- Vector3 direction = Destination - StartingPosition;
- float distanceSquared = direction.LengthSquared();
- if (direction != Vector3.Zero) direction.Normalize();
- Vector3 movement = direction * Speed * ElapsedTime;
- if (movement.LengthSquared() < distanceSquared)
- {
- return StartingPosition + movement;
- }
- else
- {
- return Destination;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement