Rotation

Missenfire

New member
Joined
Dec 18, 2019
Messages
1
Programming Experience
Beginner
Hi!

Im playing around in Unity and was wondering how I could make my model of a character face a specific direction. I have them all spawn facing the negative z axis and I only care about the xz-plane. I thought that I could calculate the angle of rotation with dot product and got v = arccos(-z/(z^2+x^2)) where x and z denote the coordinates of a random point in the xz-plane. The caracter should be facing this point as it moves towards it. I then tried the following:
C#:
  if (this.transform.rotation != (Quaternion.Euler(0, rot,0))) this.transform.RotateAround(this.transform.position, Vector3.up, 600 * Time.deltaTime);
where rot is the rotation of the point based on the xy-plane.

This does not work and I'm sure there is a much easier way of doing this.
In short I want the caracter to face the random point it is moving towards.
Thankful for responses!
 
Back
Top Bottom