Hi, i making turret and i need to rotate it , i’m tried a lot of methods but… it’s not work , i really need help at this. i don’t use dot product because i’m getting angle beetween look vector and mouse position, can someone show me an example of script

If you’re new to the math you should avoid that method and use CFrame.lookAt, which takes two (world space) positions and gives you a CFrame that points from the first point to the second, and has a position centered on the first point. CFrame | Roblox Creator Documentation

i’m not new to math and i know how to get angle, but some methoods not worked, i’m used atans , projecting into object space and dots , nothing worked

EDIT: i need methood that can give me angle in all three axis

You can use atan2 on the X and Z components to get the yaw. You can use the dot product with the Y axis to get the pitch, but the yaw will be undefined when the pitch is straight up or down. For the roll you need to first calculate a vector perpendicular to the direction and the Y axis, the take another cross to get one thats perpendicular to the direction and that vector. Then you can use atan2 to calculate the roll around these two axes the same way you did the way. This roll will also be undefined when the pitch is straight up or down.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.