Guest User

Untitled

a guest
Jul 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using UnityEngine;
  5.  
  6. public class Civilian_Street_Walk : MonoBehaviour
  7. {
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. public Transform[] target;
  15. public float speed;
  16.  
  17. private int current;
  18.  
  19. private void Update()
  20. {
  21. if (transform.position != target[current].position)
  22. {
  23. Vector3 pos = Vector3.MoveTowards(transform.position, target[current].position, speed * Time.deltaTime);
  24. GetComponent<Rigidbody>().MovePosition(pos);
  25.  
  26.  
  27. transform.rotation = Quaternion.Lerp(transform.rotation, target[current - 1].rotation, 0.02f);
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. }
  36. else
  37. {
  38. current = (current + 1) % target.Length;
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment