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

Rotating with CFrame.Angles not working right?

Asked by 4 years ago

When I click a button it is suppose to flip open a crate(no animation just an instant open). It moves the correct position but the rotation is off. It doesn't rotate properly on any axis/orientation I put it. It is suppose to be an asset for a map so my map creators can put it anywhere without having to worry about the way its facing(e.g. Facing north/east/west/south).

local thecrateLid = script.Parent.Parent.Parent.CrateTop

print("a "..crate.crateOpen.Orientation) -- Rotate to this
print('---')

thecrateLid:SetPrimaryPartCFrame(CFrame.new(crate.crateOpen.Position) * CFrame.Angles(math.rad(crate.crateOpen.Orientation.X), math.rad(crate.crateOpen.Orientation.Y), 0))

--above is all one line, there just isn't enough room on here

print("b "..thecrateLid.crateMover.Orientation) -- Orientation when rotated

It is suppose to print and rotate to

a
90, -130, 0
---
b
90, -130, 0

But instead, it is printing and rotating to

a
90, -130, 0
---
b
-40, -90, -90

I want it so that no matter what the 'a' orientation is, the 'b' orientation will match it. But I can't figure out why it isn't working. I did get the Y orientation working when it was only rotating from that. (0, Y, 0) But the (X, Y, 0) doesn't work.

1 answer

Log in to vote
0
Answered by 4 years ago

Personally, I wouldn't use CFrame as there are a few other alternatives. I would suggest using a Servo Hinge and get when the user clicks to change the angle. If you need help let me know :)

0
Agreed. CaIcuIati0n 246 — 4y
Ad

Answer this question