How can I calculate the rotation value of a model to look at a position?


#21

I think @yn97 your math understanding is lacking. You should read up on vectors, here is a good link to understanding what a dot product actually can do.


#22

The dot product also gives you a magnitude. I would never just turn at a constant rate left/right. Scale it by the ‘left’ float in my example… else you will constantly be bypassing and turning back to your target.

If you really want an angle from it then you can use atan2(left, front) which will give you +/- 180 degrees (in radians). (And then don’t do the ‘if behind, max it out’ check in my example.)

…but generally I think developers use angles only because they understand them. But it’s almost always a waste when they are just going to get converted back to something else anyway.