How to do 3D grid based movement

Godot version 4.4.1

I am making a 2.5D game with an overworld like pokemon black and white, or Casette Beast. However, I want to replicate the grid-based movement of Pokémon, but I don’t know how to do that in a 3D environment.
Can you guys give me an idea of how to do this, or at least point me to what I need to look up to figure it out. I searched Google and there aren’t any tutorials on how to do this, I could find.

Hi!

If you’re looking for grid based movement systems, I’d suggest you look at how it can be done in 2D. The game may be 2.5D and have 3D assets, but the movement logic is still in two dimensions, so however it’s done, it must definitely use the same kind of algorithms you’d use for an exclusively 2D game.

For instance, take a loot at this video:

The code uses Vector2 and CharacterBody2D, but you can fairly easily use the same algorithm and just use Vector3 and CharacterBody3D, as the logic will be the exact same.
Say you want to use raycasts to detect walls or anything, then you’d just not use RayCast2D but RayCast3D, yet, you can still check how it’s done in 2D and adapt your code.

I hope you get my point!
It seems to me that 2.5D tutorials are pretty rare, but for your purpose, I believe 2D tutorials will do the job.

Are you sure that will work? In one of the few discussions I found on this forum, someone said that you can’t just change to Vector3 and use a 3D body instead of a 2D body and Vector2. They said it doesn’t work that way.

You obviously cannot replace “2D” by “3D” in any code and it will work (that would be amazing though :joy: ).
What I’m saying is that, if you find a good tutorial or reference for a 2D grid based system, the concepts can be applied in 3D, as you’re looking for a 2D movement, with a 3D rendering.

For instance, say you have a Node2D moving on a grid. To move, you’ll change its global position x and y axis, and however you do that, what matters is that you eventually move an object on 2 axis.

In Godot’s 3D implementation, the y axis is up and the z axis is depth (or “forward”). So, to move an object on a 3D grid, you need to change its global position x and z axis instead of x and y, but the way you do it (move_and_slide function, doing a direct addition like global_position += some_movement, etc.) is essentially the same.

Taking a 2D concept and applying it in 3D is definitely something that works (it may not always be easy, I’ll give you that, but it works). A jump curve of a 2D platformer is only a curve and can be used for a 3D jump. A chess game can be implemented in 2D or 3D, as the gameplay is exactly the same, only the rendering and pawn positioning code would change. Even more abstract concepts, as noise generation or cellular automata, are most of the time seen in 2D as it’s easier to understand that way, but their algorithms can be extended in 3D.

EDIT: I’ll add that doing 2.5D is Godot mostly consists of using Sprite3D, I suppose. So, what you could do is look for resources online to implement grid based movement in 3D. I think it will be easier to start from here directly, than looking for 2D resources and convert them yourself in 3D, if you’re struggling with the idea.

I hope that makes sense. Feel free to ask otherwise :slight_smile:

Weird I tried searching resources for 3d grid-based movement in Godot early today and got nothing. Just tried it again and found quite a few things. Maybe it was worded slightly differently before. Thanks for your advice.

1 Like

Glad to read that :slight_smile:
Feel free to ask if you need more help on all of that.