views:

53

answers:

4

I've heard that you can tilt a part by a precise amount using the .CFrame property. However, I'm unclear on how to use it. The following code does not work:

Workspace.Part.CFrame = CFrame.new(90,0,45)

It is not rotating the part by 90 degrees and 45 degrees. What am I doing wrong?

A: 

The documentation states that a Coordinate Frame (CFrame) constructor that takes 3 parameters is defining a position offset. Therefore, your example code would move the part 90 along the x-axis and 45 along the z-axis. To perform a rotation as you attempted see the CFrame.fromEulerAnglesXYZ function.

Judge Maygarden
+1  A: 

First, use the CFrame.fromEulerAnglesXYZ function to create a new CFrame pointing in the direction you wish. Then, use Vector3 math to move the CFrame into the desired position. EG.

local cframe = CFrame.fromEulerAnglesXYZ(XRADIANS, YRADIANS, ZRADIANS)
cframe = (cframe - cframe.p) + Vector3.new(XPOS,YPOS,ZPOS)
Ruirize
A: 

See this page: http://wiki.roblox.com/index.php/CFrame_positioning

Bubby4j
+1  A: 

The arguments taken specify position, not rotation

Eric