Setting up a Grid with purpose?

I’m trying to make my first game ever and figured a Tower Defense game would be fun but I’m having a problem finding out how to make a grid that I can use. I managed to make a Grid overlay on the screen that activates when in play using the HUD features. However I can’t seem to make one that functions how you would thing a Tower Defense/Strategy game would work. Anyone know how to set one up? So far from what I have googled there is a $30 preset I can buy or do C++ which I am barely know. I’m hoping there is something in the blueprints that maybe I am missing.

Not sure exactly what your problem is? Can you not just make a landscape and run around in it? You can find the location of everything (all the actors) in your landscape (map) using blueprints so …?

Sorry, I’ll just start with one question. How do you set up a grid? I found the blueprint for snap to grid. But I’m trying to figure out how to use it and make a grid for tower placement. So for example if you have ever played StarCraft, when you build something it snaps to the grid and what not. I’m trying to set it up so you can see the grid that it would be snapping to. Then later would add red or green if placeable there.

I’m going to psuedo code this, just tell me if you think you need blueprint image examples.

You make grid snappable by dividing the world space down by distance snap, then break vector and round x y and z to nearest integer, remake vector, then multiply it up by distance snap.

To show buildable/nonbuildable position, you will have a stand-in blueprint that checks for flat terrain (just shoot some linetraces and if hit z is all the same, it’s flat), if unflat adjust material color to red, if flat adjust material color to green. If the stand-in is green, your click or build event will then replace or destroy the stand-in and spawn the real building in its place.

I’d start with 2DGridExecutionMacro for the grid, just type that in youtube to understand how it works. You basically spawn hISM/ISM/any other actor/component in that grid and get (whatever you want basically) out from it in an array. From there on, it’s just iterative logic from array indices (give them 2D vectors as coords if you want since you want - i pressume a 2D grid.

For snap, you just do get location under cursor by channel (or make ur own line/object trace) and use either snap to grid (float) or snap to grid (vector).

Basically, just type “UE4 2D Grid execution macro” & “UE4 snap to grid” into youtube and Mathew Wadstein will explain them simply with examples :slight_smile:

Hope it (still) helps, glhf!