Well I managed to make a test project to demonstrate a very simple grid snapping system, but I think it can be done better. I am attaching the package here so others can test it and hopefully suggest improvements. My next step is to add larger foot prints 2x2, 3x3, 5x5, etc, and figure out the best method of detecting a valid location. The current methods only good for 1x1 blocks.
NOTE: it seems my global variables did not export with the package. Please use the Playmaker menu Playmaker > Tools > Import Globals to add the globals to the project before playing.
Here is a basic rundown:
RTS Controller (1 FSM)
FSM: Mouse Tracker
This FSM tracks the mouse position and saves it as a vector3.
-finds the mouse pointers coordinates in the world.
-saves each vector to a float (Mouse X, Y, Z)
-converts each float to a INT to round it to a single digit (stores as: Mouse X INT, Y, Z)
-converts each INT back to a float (Pos X, Y, Z)
-stores the new floats to a global vector3 (Rounded Mouse Pos)
1x1 Block (1 FSM)
FSM: Can't Build On Me
This is a basic block in the world and it tells the spawned it can't build on it.
-when mouse is over it sets a global bool (Invalid Build Site) letting the spawner know it cant build
-when mouse leaves, it tells the spawer its okay now.
1x1 Block Spawner (2 FSM)
FSM: Follow Mouse
This state machine makes the spawned object follow the mouse courser and sets object material to represent state.
-sets Good Block material to indicate a valid spawn/build location
-constantly follows mouse using global vector three. The rounded vector numbers forces the spawned to snap to a grid made of 1x1 unit coordinates.
-waits for bool (Invalid Build Site) to be changed
-if bool is true meaning it's an invalid site the spawner stops following mouse and sets Blocked Block texture and waits for the bool to change again before acting.
-if bool changes and is false it returns to following the mouse cursor and again sets Good Block material.
FSM: Click and Create
This FSM waits for the player so it can spawn an object at the current location.
-waits for mouse click
-checks bool (Invalid Build Site) to see if it can build
-if invalid sets the Bad Block material letting the player know they were attempting an illegal action, returns to waiting for a mouse click.
-If a valid location spawner creates a 1x1 block bellow it.