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

Rotation of the third axis?

Asked by 9 years ago

I'm making an item drop system that clings items to the floor, even on slopes. It works well, but it drops them perfectly in line and that can look odd.

local Drop = game.Workspace.Drop
local Ray = Ray.new(Drop.Position,Vector3.new(0,-1,0)*50)
local Hit,Pos = game.Workspace:FindPartOnRay(Ray)


Drop.CFrame = CFrame.new(Pos)*CFrame.new(0,Drop.Size.Y/2,0)*
CFrame.fromEulerAnglesXYZ(math.rad(Hit.Rotation.x),math.rad(Hit.Rotation.Y),math.rad(Hit.Rotation.z))

--Drop.CFrame = CFrame.new(Pos)*CFrame.new(0,Drop.Size.Y/2,0)*
--CFrame.fromEulerAnglesXYZ(math.rad(Hit.Rotation.x),math.rad(math.random(0,90)),math.rad(Hit.Rotation.z))

As you can see, in order to give it some variation on how it's angled on the slope, I adjust the Y value to a random radian. This also works well, until I use it on a slope with a bunch of rotation values.

Watch, go into studio and make a part with a rotation of 0, 0, -30.

Now grab the green axis with the rotation tool and rotate it. Notice that x,y,z all change, instead of just y. The rotation tool automatically adjusts the others to it maintains it's previous orientation.

If anyone has the code that the rotation tool uses ( the formula to be exact ) so I can use it to rotate the "green axis" of a part while adjusting the others automatically, I'd be very pleased.

0
I made a replica of the Studio's CFrame tool, but I edited so it's the CFrame tool with local and world axis CFraming(toggled by pressing m) and it's also a mixture of the rotate tool(toggled by pressing f) so i'm not sure if that's much help, but also I don't understand your problem here much.. on slopes then you're wanting to stick the object according to the slope? Goulstem 8144 — 9y
0
Yes, I'm clinging a part to sloped terrain. This can be done by just settings it's rotation to that of the slope. The problem is, if you drop multiple things, they line up perfectly and it looks odd. I want to be able to rotate it while it's on the ground to make it look a little more realistic. Cawlonee 0 — 9y

Answer this question