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

How would you add value to CFrame?

Asked by 10 years ago
Workspace.Part1.CFrame = Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10),0)

This only sets it to that degree. + CFrame.Angles(0,math.rad(10),0) wont work it tells me it needs a vector 3, which I tried and wouldn't work either.

What I plan on doing is adding +1 to math.rad (10) every 1 second. If I do this:

Workspace.Part1.CFrame = Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10),0)
wait(1)
Workspace.Part1.CFrame = Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10),0)

It'll stay at 10, not move on to 11.

3 answers

Log in to vote
2
Answered by
duckwit 1404 Moderation Voter
10 years ago

You can use the addition operator, + between a CFrame and a Vector3, between a Vector3 and another Vector3 but not between a CFrame and another CFrame - the Offical ROBLOX Wiki page on CFrames has a section devoted to explaining the CFrame Operators.

Because of the way matrix math works (which is what CFrames effectively are) a multiplication has an additive affect, so:

part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(10),0)
part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(10),0)

Does exactly the same transformation as:

part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(20),0)

If you do use the + operator with a CFrame, you must use it in conjunction with a Vector3 - this will work, if it does not, you are doing something wrong and would need to show us what it is for us to help :)

0
Haha, I didn't realise it was you until I'd posted my answer - let me know if you need anything else explaining, I don't think I understood your question entirely. duckwit 1404 — 10y
0
Lol hey! Btw I tried CFrame.Angles(0,math.rad(10),0) twice, it doesn't rotate to 20, it just stays at 10 Orlando777 315 — 10y
0
BTW I updated the question. Orlando777 315 — 10y
0
NVM, It works now. I have no clue what was wrong. Thanks though. Orlando777 315 — 10y
Ad
Log in to vote
1
Answered by 10 years ago
Workspace.Part1.CFrame = CFrame.new(--[[X Axis]],--[[Y Axis]],--[[Z Axis]]) * CFrame.Angles(0,math.rad(10),0)

You would put the position vector in the CFrame.new() parenthesis, just like you would with a Vector3.new()

0
I don't need to change the position. Just adding +1 on the Y axis rotation value. Orlando777 315 — 10y
Log in to vote
0
Answered by
jav2612 180
10 years ago
Workspace.Part1.CFrame = CFrame.new(Workspace.Part1.CFrame * CFrame.Angles(0,math.rad(10), 0))

I believe is correct.

0
Same Error. Orlando777 315 — 10y
0
Sorry about that I havn't used CFrame in a while. Editted it. jav2612 180 — 10y
0
It might be what TurboFusion said. Like I said I havn't used CFrame in a while. jav2612 180 — 10y

Answer this question