Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I keep a model rotated by 90 degrees while it aims?

Asked by 5 years ago

BodyGyro.CFrame = CFrame.new(Vector3.new(0, 0.5, 0), MousePosition)*CFrame.Angles(0,math.rad(math.pi/2),0) A person recommended that I multiply it by CFrame.Angles, but this didn't really seem to help at all. I've tried changing the axis to x, y, and z, but they all seem to do nothing when I'm trying to keep the model Rotated by 90 degrees to keep it upright. Am I doing something wrong? For context, I'm trying to have a turret that always points towards the mouse's hit position. Aiming towards the mouse's position seems to work perfectly, but the model seems to still be sideways at all times instead of upright.

0
did you loop it? greatneil80 2647 — 5y
0
I wasn't notified of your comment for some reason, but yes. It's located within a loop that is constantly going. The loop is entirely fine since it aims at my mouse position perfectly. The only issue is that the model is always sideways. ZoltofLightning 27 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Found out finally what was wrong after trying to get an answer in the SH Discord since Tuesday. It looks like I misinterpreted what the user named calidad was telling me previously.

multiply that by CFrame.Angles(x, y, z) they should be in radians

so u can do math.pi/2 since

pi rad = 180 deg

and stuff

Looks like I thought he meant to do math.pi/2 converted into radians, so I was doing math.rad(math.pi/2) when he meant literally just doing math.pi/2 since that's how radians work. It took a bit of reading into multiplying cframes with no answers, then looking into .angles, then looking into radians. The wording is a bit confusing at first, but now I get what it means. math.rad just converts degrees like 90 into math.pi/2 rather than what I previously thought was some weird special type of value called a radian that normal numbers needed converted into.

Ad

Answer this question