How can I do grid based movement?

Basically i want to achieve something like this - YouTube but without space between tiles, I want my character to jump from center of one tile to center of another. (only in certain levels, in every other i want him to move like regular 3rd person)

I don’t know where to start, everything i found is trun-based mouseclick only.
I feel like moving actor by X points in certain axis/direction is wrong approach.

Create a grid of actors using 2d Grid Execution Macro. When you want to move your pawn, trace to the object you’re planning to move to and get its location. Use a Timeline+Lerp / Tick+Interp to shift the Pawn to that tile.

I don’t know where to start,
everything i found is trun-based
mouseclick only. I feel like moving
actor by X points in certain
axis/direction is wrong approach.

Perhaps it is not wrong but might prove quite inflexible further down the line. Essentially, before you move, you should obtain as much info about the object you’re moving to as possible. This will allow you to handle behaviour before the transition, rather than on arrival.

Check out my Sokoban template Here , it covers grid movement.

i created what i wanted based on your project and it works great, thanks !

any way to make grid and keep it in the editor? (in case i want to build level around it)
by keep it i mean visible in the editor all the time not only when i press play

Sure, add components in the ConstructionScript:

And place the object in the level.

1 Like

that works great, thank you.
but here comes another problem, how can i interact with each cube?
before i had events now i have no idea how to for example change material if my character hits cube

In the ConstructionScript, add the components to an array and register them in Event BeginPlay with the necessary Events you want to you use:

In this case, the components now have a chance to respond to clicks and overlaps. (enable mouse click events in the controller, too)

For example:

In your Pawn/Character you must have a collider, use it to identify world elements you overlap with:

218127-capsule-overlap.png

1 Like