Simple code to face target once i click on object. Which works as i would like.
Vector3 direction = (position - transform.position).normalized;
Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0f, direction.z));
transform.rotation = Quaternion.RotateTowards(transform.rotation, lookRotation, Time.deltaTime * turnSpeed);
Biggest issue right now is that if i pass in raycast hit.point it does not rotate it correctly.
I have set the update rotation to false (to disable agent update rotation)
The basic idea is that i would like to handle rotation without NavMeshAgent the same way i handle it once i click on target (to face it)
For position i pass in target (which is Transform) .position (Vector3) and in click state i pass hit.point (Vector3) from Raycast hit.
Is there something i could do to normalize this and rotate to Raycasthit hit.point location the same way i do for facing target?
I am using NavMeshAgent
I do not want to use NavMeshAgent rotation handler because rotation is way too slow and it starts to walk before rotating object (for example if i want to walk in 180 degree then rotation happens after period of time and differs from then i face target using script)