Skip to content

Example

The following steps demonstrate one possible setup for using the snap functionality in a game.

Add the Grid Actor

  1. Create a project by selecting the third person template.
  2. Open the project.
  3. Go to the Place Actor tab and search for the Central Grid actor.
  4. Drag the actor into your world and set the grid visuals to true.

Get Snap Parameters

Add the function

  1. Open the character blueprint or any other blueprint you wish to place the logic into.
  2. Create a reference to the Central Grid actor.
  3. Drag out from the actor reference and search for the Get Snap Parameter function.
  4. Create a reference to the Camera Component and connect it to the Target Object pin.
  5. Set the Snap Type to Highest Corner.
  6. Tick all Snap to checkboxes.
  7. Split the Lock pin and create the three boolean variables named Lock X-Axis, Lock Y-Axis and Lock Z-Axis and connect them to the corresponding Lock pin. Alternatively you can right click the pins and promote them to a variable.
  8. Split the OUT pin and promote the Snap Location to a variable.

Get Snap Parameters

Hook up events

  1. In this example we use the Left Ctrl, Left Shift and Left Alt key to toggle the boolean variables.
  2. To use the snap location, simply facilitate the built-in Unreal Engine Spawn Actor function to spawn any actor at the snap location. In this example we use the Left Mouse Button to execute.

Get Snap Parameters

Get Snap Parameters