Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. public float speed = 2.0f;
  2. public Transform goal;
  3.  
  4. public float accuracy = 0.1f;
  5.  
  6. void LateUpdate()
  7. {
  8. transform.LookAt(goal.position);
  9. Vector3 direction = goal.position - transform.position;
  10. Debug.DrawRay(transform.position, direction, Color.red);
  11. if (direction.magnitude > accuracy)
  12. {
  13. transform.Translate(direction.normalized * speed * Time.deltaTime, Space.World);
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement