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

Aligning a part to the floor?

Asked by 8 years ago

I am making a hoverboard and I need to have the part always rotating so it is aligned with the rotation of the ground. How would I do this?

0
Please elaborate on this. At the moment I'm not sure what to visualize; could you maybe show a picture? Legojoker 345 — 8y
0
I think he means that the hoverboard should be parallel with the ground. Spectrobz 140 — 8y

1 answer

Log in to vote
1
Answered by
Spectrobz 140
8 years ago

So first you wanna find the rotation of the surface, let's call the part under the hoverboard "SurfacePart".

You would use this function to get the part rotation from its CFrame (The "x,y,z" values are the part position, while the other values are the rotation of the part)

local x,y,z,xx,yx,zx,xy,yy,zy,xz,yz,zz = SurfacePart.CFrame:components()

Then you would get the hoverboard CFrame (we will call it "newCFrame") by applying the rotation values to a new CFrame value.

newCFrame = CFrame.new(0,0,0,xx,-yx,-zx,xy,-yy,-zy,xz,-yz,-zz)

Of course you need to apply the board position, else the part will be placed at position (0,0,0). The board position would be called "Position" (Vector3 value)

newCFrame = CFrame.new(0,0,0,xx,-yx,-zx,xy,-yy,-zy,xz,-yz,-zz) + Position

You should read this to learn how CFrame works http://wiki.roblox.com/index.php?title=CFrame

0
Of course you would rotate the newCFrame as you need. Spectrobz 140 — 8y
Ad

Answer this question