Quantcast
Channel: Answers by "Peter G"
Viewing all articles
Browse latest Browse all 90

Answer by Peter G

$
0
0
I see what you're trying to do, and it could work. It just seems like a rather circuitous way of doing it. I might try something like this. Vector3 offset = target.position - transform.position; Vector3 axis = Vector3.forward; //You will probably need to change the axis. // I know you said that it was wrong when you used look at so it's not going to be Vector3.up //but it'll be one of the other ones. targetRotation = Quaternion.LookRotation ( offset , axis); //Create a rotation looking at the turret transform.rotation = Quaternion.RotateTowards( transform.rotation , targetRotation , rotateSpeed * Time.deltaTime ); //Actually rotate towards the target.

Viewing all articles
Browse latest Browse all 90

Trending Articles