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

CFrame + CFrame?

Asked by
LuaQuest 450 Moderation Voter
8 years ago

Just wondering, why is it CFrame * CFrame for adding positions? Why not:

Something.CFrame = Something.CFrame + CFrame.new(0,10,0)

Instead of:

Something.CFrame = Something.CFrame * CFrame.new(0,10,0)

Just curious, thanks for reading.

1
Not in terms of position. You add 2 CFrame positions by multiplying them. My question is, why? LuaQuest 450 — 8y
0
#Geomtry MessorAdmin 598 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

If you want to add a position you would add a Vector3.

Something.CFrame = Something.CFrame + Vector3.new(0,4,0)

This just modifies the position and ignores rotation completely.

When you multiply two CFrame values, you're transforming based on the first CFrame's rotation. In other words, if I have a rotated part, multiplying the part's CFrame by CFrame.new(0,4,0) will move the part 4 studs up relative to the old CFrame, whereas just adding a vector will move it up by 4 studs.

When I add Vector3.new(0,4,0) to the part's CFrame: http://i.imgur.com/rkWFVX4.png

When I multiply the part's CFrame by CFrame.new(0,4,0) http://i.imgur.com/i0VWSUK.png

Ad

Answer this question