First-Person Grid-Based Movement

Hey!

My goal is to create a 3D, First-Person Grid/Tile-Based Dungeon crawler, but I’m new to UE5, coding and blueprints. I took some time to watch tutorials on how to set up a character controller, but none of them set it up to move one tile at a time.

I would like there to be a slight delay between movements, and the player should be able to turn left, right, as well as take a step back.

If you’ve ever played games like Might and Magic or Wizardry, what I’m looking for is something along those lines.

Thank you!

1 Like

See if you could work with something along the lines of:

This should be set up with Enhanced Input but I could not be bothered, hope you can add it. Here’s the (UE5.2) project:

This is just a stub and can be vastly improved. Here, you can walk, rotate and not smash into walls.

1 Like

Do you know if this code works in version 5.3? I tried it out but I couldn’t find the “switch on eDirection” node

It does. It’s an enumerator that you’d need make yourself. There’s also the attached project. The node and the method are optional, though. Many ways to make this work.

Nice! I managed to get it shortly after that, thank you.

I’ve been trying to improve the collision detection on it where the character will either move the full movement or not at all but have been stuck.

I figured the logic would have been something along the lines of, “If a collision is detected between point A and point B then player location equals start location else player location equals end location”.

This is already handled in the example above. In a much simpler way, too;

  • we trace ahead to see if something blocks the way
  • if so, the TL does not play

Admittedly, a capsule trace could make more sense.

1 Like

I previously ended up switching to capsule trace and turned on sweep on the Set Actor Location, the character just really wants to bump into walls for me.

I must have missed something, possibly in my timeline template.

Not sure how this could be relevant. The trace produces data - use it. That’s before you even start moving or sweeping.

No need to run the TL if the way is blocked anyway.


Consider getting it working with regular line trace first, and only then switch to capsule trace. Perhaps it’s not set up correctly. If in doubt, post relevant script. Also, sweeping in a system like this seems unnecessary (but who knows what you’re up to!). Unless you use Sweep instead of Tracing that is.

This sounds a bit like:

1 Like

This helps so much! Thank you once again. This is the logic I was trying to figure out but didn’t know how using Blueprints.

@Everynone Hello my friend. Thanks for this instructions you shared some time ago! I am trying to use this movement mechanic and it does work what you shared. However, I am trying to make W,A,S,D to move while keeping the camera facing the same location, and using Q and E to turn the camera location to the sides. Could you please help me with this? Thanks a lot.

1 Like

all you’d need to add is rotation so use

RInterp on a Timeline or something and GetActorRotation +/- 90 on the Z axis

Updated to UE v5.3 with the extra moves mentioned above and IMC support:

2 Likes

Hi. I was looking for the exact same thing but couldn’t make it to work. I can only move backward and left, same for rotation. I tried looking for the negate keys and everything seems fine. Any UE parameters I need to set up to make it work ?

If someone got the same issue as mine I just fixed it by rebinding manually each input istead of checking if a direction is an input value is negative or positive. For a strange reason my controls wouldn’t go under 0 so the script had struggles determining if it was forward or backward input.
Just create input actions for each movement and bind it in the script

Sharing my findings in hope this can helps someone in the future maybe, have a great day

This “template” got some additional features, like free look and some other tweaks that were requested behind the scenes:

Sounds like the Negate modifier is missing or was added in the wrong place:

2 Likes

This is outstanding! Do you mind if I use this for my Kid’s game dev course? We homeschool and he wanted to learn Unreal, so I’ve been teaching him what I know and getting him Udemy courses to advance his skillset. He’s already made 3 games, using the courses and has already started working on his own projects.

1 Like

That is adorable. Please do whatever it takes. :sunny:

1 Like

I know, right? It started out wanting to mod Fortnite, so I took it a step further and put him in basic courses for UE. I’m a 3D animator and modeler, by trade, so all this blueprint stuff is way beyond my paygrade. He’s already done a survival game, a run and jump platformer and a 3d shooter, but I’m trying to work with his modeling skills. I’ve got him using Blender, but I’ve spent the last 20 years in Maya, so there’s always something.

A quick question, is there a way that you can speed up the movement and have the camera angle up or down when moving along an incline? I want to put together an environment prototype lesson for him, where he has to work on his own, using props he’s made in Blender instead of kits that came with his tuts, we bought or are free. I want him to use this as his base. I’m reviewing your blueprints, but I’m not seeing where I would hook something like that in, much less where to hook either the camera movement or a way to speed up grid movement.

It’s this bit here, in the bottom right:

Note that Turn Left / Turn Right are, apparently, swapped around. My bad :man_facepalming:. That needs fixing.


Also note this was never set up with ramps in mind so the actual ramp movement method would be awkward and would need to be revised or even entirely replaced with AI NavMesh movement.

Many ways to pull it off:

  • a pro-active way would be to set up some traces. Same function, swap the Line Trace for a Capsule TraceHits will produce a Normal - a direction the hit surface is facing:

Dot Product said Normal with VectorUp to get a value range of -1 <> 1 indicating how steep the ramp is. Work that pitch in during the movement update to a smooth transition:

More would needed here as the next thing you’d want is a ramp that goes down.

  • a reactive way - sample the surface we’re traversing on, something the movement component already does:

This is just pseudoscript, ofc. Not sure if helpful at all.


The thing is that when you get round to it in a somewhat serious manner, one would have a feature guideline, a design doc detailing how things are supposed to work. There was none and things escalated so it needs refactoring now.

You could probably get away with it all in the current system, it’s a matter of getting more data from the world via tracing.

Nice. My Son actually showed me how to use the timeline properly, as I didn’t know how to do it, so I changed it there. I didn’t realize that you had added a movement speed to the blueprint, itself. Man, if you saw my BPs. Basically everything is commented. I do a tad bit of coding, but I’m not a decent enough coder, so I comment everything.

Oh, that’s perfect. His current project is building a 3 level shooter on his own, using assets he’s modeling and I’m texturing. He wanted to make a sentry gun and he’s already learning path tracing on his own. He was very proud when he showed me his prototype turret following the controller and breaking the lock, when you went around obstacles. My next project for him was going to be an RTS prototype, which means I need to learn how to do grid movement, but I have a soft spot for Dungeon Crawlers (I did all the art on an open source one called BTBuilder), so I wanted to do that instead. All of this will help out a lot. Thanks so much, Everynone! o7