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

How to effectivly use the CFrame rotation?

Asked by
1N0body 206 Moderation Voter
9 years ago

Hello, I would like to know how I am able to use the CFrame rotation smoothly. So I am able to rotate an object smoothly.

Here was my experiment but it was a failure:

while wait() do
script.Parent.CFrame = CFrame.new(script.Parent.CFrame) *                                                                       CFrame.Angles(0,0,script.Parent.Rotation.Z + 1)
end

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

The parameter to CFrame.new(pos) is a position, which is a Vector3, not a CFrame. Use

either

CFrame.new( script.Parent.CFrame.p )

or

CFrame.new( script.Parent.Position )

You probably want to rotate by less than 1. CFrame.Angles parameters, unlike the Rotation property, is measured in radians not degrees. Though it's probably better that you just keep track of the angle rather than read the property as you are doing:

local angle = 0

while wait() do
    angle = angle + 0.1
    script.Parent.CFrame = CFrame.new(script.Parent.Position)
    * CFrame.Angles(0, 0, angle)
end

0.1 radians / .03seconds is 3.33 radians / second or approximately one revolution per second.

0
Thanks 1N0body 206 — 9y
Ad

Answer this question