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

Why is my use of CFrame.Angles() defaulting to a random position?

Asked by 7 years ago

I'm currently making something where a player can press R and a part gets rotated by 90 degrees, but for some reason it always defaults to some other rotation (270 degrees changes to about 10, 90 degrees changes to about 63, etc). This is essentially what I am using right now:

--NOTE: position is a Vector3 and rotation is an integer
CFrame.new(position+Vector3.new(2,2,2))*CFrame.Angles(0,rotation,0)

The position itself works fine, but the angle is never correct. Any help would be appreciated, thanks!

0
whats the value of rotation? Volodymyr2004 293 — 7y

1 answer

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

CFrame.Angles' three parameters are expected to be in radians, not degrees. This can be remedied rather easily:

CFrame.new(position+Vector3.new(2,2,2))*CFrame.Angles(0,math.rad(rotation),0)

Hope this helped.

More on CFrame.Angles & math.rad.

0
Okay, thanks! ChipioIndustries 454 — 7y
Ad

Answer this question