GTA type pedestrian Traffic - Character Navigation Controller.

Hey!

i was using a tutorial to spawn some NPC’s that move around a waypoint, the waypoint works, but i’m having some issues with the Character Navigation Controller.
Essentially I’m not really sure what he intended for the variables below in the class. I tried looking into Unity’s Character controller but I don’t think it automates movement.


I would like someone to break down how to get about creating a navigation controller, that allows the NPC to move from its current position to an entered destination.


here is what I have so far.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharacterNavigationController : MonoBehaviour
{
    CharacterController character;
    public int movementSpeed;
    public float rotationSpeed;
    public float stopDistance;
    public Vector3 destination;
    public bool reachedDestination;

    private void Awake()
    {
        character = GameObject.Find("Character_Female_Coat_01").GetComponent<CharacterController>();
    }

    // Start is called before the first frame update
    void Start()
    {
        movementSpeed = 1;
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); //not using this yet
        character.Move(desination * Time.deltaTime * movementSpeed);
        if (destination != Vector3.zero)
        {
            transform.forward = destination;
            reachedDestination = true;
            Debug.Log("reachead destination: " + destination);
        }



    }

    public void SetDestination(Vector3 value)
	{
        destination = value;
	}
}

Try to use NavMesh