Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using UnityEngine;
- public class Civilian_Street_Walk : MonoBehaviour
- {
- public Transform[] target;
- public float speed;
- private int current;
- private void Update()
- {
- if (transform.position != target[current].position)
- {
- Vector3 pos = Vector3.MoveTowards(transform.position, target[current].position, speed * Time.deltaTime);
- GetComponent<Rigidbody>().MovePosition(pos);
- transform.rotation = Quaternion.Lerp(transform.rotation, target[current - 1].rotation, 0.02f);
- }
- else
- {
- current = (current + 1) % target.Length;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment