Rotate on Click To Move Controller

Hi all! I’m working on a game where you click to move the player. There’s so many ways to do this, but I decided to use the Move method and character controller to prevent my character from going through walls(and for the sake of detecting walls). Well, I think it is because the nature of the Move that I found it difficult myself to rotate the player.

I’m trying to make the player rotate to the direction it’s moving whenever the mouse button is clicked. Does anyone know how I can do this? Would I have to use another move method and detect collision through code?

Control.cs

void Start(){
        controller = GetComponent<CharacterController> ();
    }
    void FixedUpdate () {
        UpdateMovement ();
    }
    void UpdateMovement(){
        RaycastHit hit = new RaycastHit ();
        if (Input.GetButtonDown ("Movement") && canMove) {
            Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
            if (Physics.Raycast (ray, out hit)) 
                target = new Vector3 (hit.point.x, characterHeight, hit.point.z);
        }
        if (Vector3.Magnitude (target - transform.position) > 0.3f) {
            if (controller.isGrounded) {
                moveDirection = (target - transform.position).normalized;
                moveDirection = transform.TransformDirection (moveDirection);
                moveDirection *= moveSpeed;
            }
            moveDirection.y -= gravity * Time.deltaTime;
            controller.Move (moveDirection * Time.deltaTime);
        } else
            transform.position = target;
        waypoint.position = target;
    }

look at position clicked

Position Clicked?? I don’t understand…

this might be what you need just change it from above to perfered direction

Thanks, but I’m not quite sure how I can use this. I’m trying to add proper rotation to my character script, but it’s a bit tricky when using a character controller for this format of gameplay. Using anything but Move or Simple Move may help add rotation easier, but I will not be using a character controller or collision flags if I’m using another move method like Lerp or MoveTowards. Raycasting would probably be best for collision detection imo.

Oops, I meant:

and

mabby