- Home /
2D Sandbox physics problem
I have a problem with implementing sandbox like functionality to my game. The idea is that I have a huge object that is composed of multiple smaller blocks and when player cuts through the object the entire structure would technically be cut in half. So the smaller piece should fall off. Originaly I would have a gameObject with blocks as children of that object and they are stored in the array. Next when player modifies the object, the system would mark all the blocks that are adjacent to empty(air) block and using these edge blocks I would isolate disconnected parts. But that would take a lot of processing power. So next idea was to have 2D rigid bodies that are connected using joints, but huge number of those would impact performance as well. So here is my question: how do I tackle this? I'm more interested in the theory behind it rather than the code and examples themselves. Or should I stop using engine at all and start from scratch?
Here is the example of what I want to achieve: http://i.imgur.com/HJ4YTDi.gif
At first the entire thing moves as one entity but then, because no other blocks connect two pieces, the smaller part detaches and becomes another entitiy.
Answer by Xare · Jun 27, 2014 at 05:19 PM
If you want extremely precise cuts, you will have to generate sprites/meshes depending on the cut the player has made. Otherwise, you can try to recreate what fruit ninja has made and have one prefab for the whole object and another prefab for one half of the object. When player cuts your object, instantiate 2x half objects dependant on the position of the cut and make on of them fall down.
Sorry I might not have been clear but here is the example of what I want to achieve: http://i.imgur.com/HJ4YTDi.gif At first the entire thing moves as one entity but then, because no other blocks connect two pieces, piece of it detaches as its own entitiy. I'll edit my post with this information.