How do I create a gridded volume space?

How would i go about creating a snap-space volume? To further explain, i need to create a space that is box-style gridded. And make that grid’s space snap, so that in each space of the grid itself, objects can snap when placed by the player. The player needs to be able to pick up the object and place it within the grid. Then the object needs to snap to the nearest target grid space. I am not sure about how to set this up at all…and i have a very basic understanding of UE4.

What do you have so far? Think about the steps you’ll need in order to accomplish this setup, try to work through each one, and post a specific problem if you get stuck.

Here are my recommended steps:

  • Create a parent actor that all movable children will derive from.

  • Figure out how to use mouse interactions on these actors so you can set an active movable actor when it’s clicked on.

  • Use a single line trace from your mouse to determine where the movable object should be moved to.

  • Use a modulo with your grid size for x/y values so the positions clamp to the arbitrary grid size.

When you say “Create a parent actor that all movable children will derive from.” you mean a spawn point for the objects to appear?

By a parent actor I mean a new class that derives “Actor” for inheritance purposes, probably called something like “MovableActor”.

The concept of inheritance is that when you start adding all the different objects that you want to be able to move around on your grid (“MovableCar”, “MoveableHouse”, etc.), you can simply create them with their parent class as “MovableActor” instead of just “Actor”. The benefit here, when they’re children of “MovableActor”, is they’ll automatically inherit all parameters, functions, components, and interfaces that you’ve declared in “MovableActor”.

You can skip that step if inheritance is new to you and it’s not something you want to bother with right now. Instead, just continue with figuring out how to receive mouse interactions on actors (there’s blueprint examples in the “Context Examples” project available on the marketplace).