Guest User

Untitled

a guest
Nov 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. void Update()
  2. {
  3. if(flagJourney == false)
  4. {
  5. endPosition = P1;
  6. startMarker = transform;
  7. startTime = Time.time;
  8. flagJourney = true;
  9. }
  10. else
  11. {
  12. float prec = (Time.time - startTime) / (0.1f);
  13. if(prec >= 1)
  14. {
  15. flagJourney = false;
  16. if(prec > 1)
  17. prec = 1;
  18. }
  19. transform.position = Vector3.Lerp(startMarker.position, endPosition, prec);
  20. Debug.Log(Vector3.Distance(transform.position, endPosition)); // вывод дистанции, которую проходит объект за 1 проход
  21. }
  22. }
Add Comment
Please, Sign In to add comment