I would like to make a small third-person building game where players can come together and build anything they want with each other.
Basically I want to give players the ability to move and clone Actors across a grid. Nothing too fancy. I want the tools to be selected through a sort of “hotbar.” The cursor should be visible at all times; I want it to only move the camera when you right-click.
I specifically want a Move tool, a Clone tool, and a Delete tool.
Move: Click and drag an Actor (block of some sort). It would move across a grid and collide with other Actors.
Clone: Click an Actor to clone it. The cloned Actor will appear immediately on top of the Actor that was cloned. If the Actor cloned has other blocks on top of it, the clone will appear on top of those blocks instead.
Delete: Simple: Will delete an Actor. I would prefer if it had some particle effect as well.
I already have a system in place for hosting and joining servers. What I would like help with is the building part.
I’ve already searched for tutorials on this everywhere: No luck.
Thanks in advance!
Well, for the move tool:
Perform a trace from mouse screen position to world and if it hits an actor, save it as reference, and start moving it around by updating it’s position to the new traced location in the world. On another click clear the reference and stop updating.
For the clone tool, well:
Same thing, perform a trace to get the actor, and then spawn another version of it. The stacking on top could be tricky
For the delete tool, it’s quite easy:
Perform a trace, and destroy the actor. Before destruction spawn a particle effect.
I once worked on a similar system (with the only difference that most objects snapped to predefined points, not a mathematical grid) and wasted a lot of time with these 2 problems:
To snap your objects to a grid, use the math function “snap to grid” when building/moving objects (it only takes in float values, so you have to split the hit vector of the tracer from the camera to your mouse, snap it to the grid and then recombine.
Build your whole system around multiplayer from the very beginning. It’s a lot of work to make a singleplayer system work in multiplayer, but any multiplayer system works in singleplayer too (since in a sologame the player is always the server, but in multiplayer only sometimes).
I hope that saves you some of the hours you’ll put in this project and later realize that they were wasted