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

What are world to object coordinates?

Asked by
52M 10
10 years ago

This is used allot in the stamper script. I am trying to make one myself and no matter how I go about it I still run into this question.

All I know about it is that its a CFrame Method.

1 answer

Log in to vote
0
Answered by
Destrings 406 Moderation Voter
10 years ago

World coordinates have an origin, that's (0,0,0). But what if you want to know a part's position relative to another part, that's when you use object coordinates. Object coordinates are coordinates where the object position is the origin of the coordinate system. For example

partA = Instance.new("Part", Workspace)
partB = Instance.new("Part", Workspace)
partA.Anchored = true
partB.Anchored = true

partA.BrickColor = BrickColor.new("Bright red")
partA.CFrame = CFrame.new(25,0, 23) --Just moving it somewhere
partB.CFrame = CFrame.new(25,5, 23) --Moving it 5 studs above

print(partA.CFrame:toObjectSpace(partB.CFrame).p) --0, 5, 0 because partB is 5 studs above partA.
Ad

Answer this question