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

Why are these rotations acting weird?

Asked by 5 years ago
Edited 5 years ago

I'm not going to past my script here since it's over 100 lines, but here is an example of what I am doing.

Part1 - Orientation = -68.91, 44.01, 44.01

Part2 - Recently cloned

I want to set Part2's Orientation to the same as Part1. Now through my script process, I have Part1's Orientation as X, Y, and Z (separate variables).

I then go to set Part2's Position and Orientation to Part1's...

local partCFrame = CFrame.new(PosX,PosY,PosZ)

local rotation = CFrame.fromEulerAnglesXYZ(math.rad(RotX),
                                    math.rad(RotY),
                                    math.rad(RotZ))

partCFrame = partCFrame * rotation

Now the Position works perfectly fine, but the Orientation of Part2 gets skewed somehow and I can't figure out why.

Part2 - Orientation = -42.15, 69.57, -16.96

Here is a picture of how it looks, the Blue is Part1, the Green is Part2. gyazo.com/64563902fa28379887c64adfa3221007

1 answer

Log in to vote
1
Answered by
Tomstah 401 Moderation Voter
5 years ago
local rotation = CFrame.fromEulerAnglesXYZ(math.rad(RotX),
                                        math.rad(RotY),
                                        math.rad(RotZ))

Your rotation is already in radians first of all. Get rid of math.rad to begin with, then we can work from their if your problem resumes. Another thing, you could do:

local CFrame = CFrame.new(Part1.Position) * Part2.CFrame:toEulerAnglesXYZ
Ad

Answer this question