0 votes


What I have Currently Working
So I have:

  • orthographic render of a isometric scene as a 2D texture.
  • I also have a character which I have rendered 8 different directions out
  • I have the player able to move around the world using an AStar path finding grid

The Problem
The AStar grid is not consistent with the camera's projection matrix. See below (red dots are AStar navigable nodes:
enter image description here ( https://imgur.com/a/Baplqpl.png )

  • The red boxes are navigation nodes
  • The background and character are (more or less) just 2D textures with a normal map.
  • Notice that up/down/left/right/diagonal with respect to the game's surface is different than it is with respect to the navigation nodes.

As you can see, the AStar navigation nodes allow the player to move in horizontal/vertical/diagonal directions which are not consistent with the camera's projection of the surface of the world.

I have rendered 8 different directions of movement for the character, but those are only for diagonal / vertical/ horizontal movements in the world's projection.

everything working fine with the AStar path finder, but the problem is that the astar navigation nodes aren't consistent with the camera projection. Ie, it is a 2d basic grid, but it is not "parallel" to the surface/ground of the isometric world. Which results in the character walking slightly off from how they look like they are walking (for example, I only want the character to be able to move at even 45 degree angles because those are the directions rendered out of the character moving.)

Attempted Approach
I need to produce an Astar map that is consistent with the surface projection. So to do this, I tried to export the camera's projection matrix from blender and apply that onto the GridMap to move the nodes such that they are consistent with camera projection. However I have not found a way to do this successfully.

asked May 16 in Engine by Jeremy. Allen. Wilds (12 points)

1 Answer

0 votes

There are 2 possible approaches:
option 1:
1. internally, keep the navigation nodes as an orthogonal grid. Use a transform to convert points between navigation context and screen context.

option 2:
Use the screen coordinates only. Put the navigation nodes where they should be visually. Override the default estimatecost and calculatecost methods of the AStar node, in such a way, that it matches the screen movement. This should be easy enough - all you need is to know the ratio between vertical and horizontal movement speed.

#on screen, character moves twice as fast horizontally than vertically
#for you, the ratio may vary depending on angle of projection
var ratio_v_vs_h=2.0

func _estimate_cost(point1, point2):
    var temp=(point1-point2)
    return temp.length()
answered May 17 by KohuGaly (128 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.