Placement System Saving

Recently I signed onto a project that requires a placement system. Tackling this placement system seemed complex until I realized I was over complicating things i.e multiple placement canvases, angles etc. After simplifying and optimizing my placement module I ran into another problem. Saving and loading placed objects. This can normally be easily fixed using…

Saving placement

-- Convert objectCFrame into object space CFrame (relative to canvas)
    local objectSpaceCFrame = playerPlot.Canvas.CFrame:ToObjectSpace(placedItem.BasePosition.Value)

Loading placement

-- Unpack object space CFrame string and convert that into world space CFrame
    local objectSpaceCFrame = CFrame.new(unpack(components))
    local worldSpaceCFrame = canvas.CFrame:ToWorldSpace(objectSpaceCFrame)

I have this idea implemented in my module right now and it’s working flawlessly. However, there’s an issue. Using those functions requires both surfaces to have the same rotation. What if I wanted to have all the plots surrounding a central area?

How would this be accomplished?

My second question is how would I rotate all of the objects on the surface after they are placed? i.e a player wants to move plots, but since the new plot is facing a different direction then the last, he or she has to click a button to rotate the builds to face the proper direction. How can I move all of the objects as a whole? A perfect example of this is Lumber Tycoon 2 by Defaultio. You are allowed to choose any plot, place anything anywhere on the plot, save the plot, load into another physical surface and even rotate your builds. If anyone has an idea on how I can accomplish this please let me know. Thanks!

3 Likes

You could use the Module above as reference, or ask the OP

(I wish I could help but I am not an Expert on CFrame yet.)

1 Like

I’ve taken a look at that. It doesn’t help me in any way unfortunately. My setup, like Ego’s is also an object orientated approach, but the is completely different. That post doesn’t address the issues I have. Thanks though!

1 Like

If the question is purely just how do you rotate the all the objects around the plot, then just save the relative object space cframes, then multiply the canvas cframe by the angle you want and then place all the objects using the new center cframe.

5 Likes

That’s actually what Lumber Tycoon 2 does. How did I not realize this and think of this sooner haha. Thanks!

1 Like

I like the idea and design. I just wonder, does it save when you leave the game? I’m trying to make a game where players have plots that they can build a small lab in, and have it save for the next time they play.

Edit: Nevermind, I didn’t watch the end.