Raycast/pathfinding with isometry problem

Hello I am facing the following problem. I want to set up a simple AI for the enemy in an isometric game, if he sees the player (raycast from enemy to player) - he runs after him, the problem is that diagonal sprites block the view of the enemy.
If you are using top-down view - everything works fine:

But if you are using isometry the following happens:
Raycast collides not with the collision mask of the object, but with this box outlining it.

Is there any way to fix/work around this?

Is the black strip in the second image a rotated sprite, or is it the actual image? I suspect the second, and in that case you can create a custom collision mask for the sprite, rather than using the default (which is the border of the image).

No, its a rotated sprite. That’s the problem, raycast is getting blocked NOT by collision mask of the sprite.

It seems like the actual problem is pathfinding, not raycast.
In other words, the enemy can see the player, but cant reach it.
I’ve recorded a video with more detail.

Hi, I quickly built a similar scene with a player, enemy and an oblique line as obstacle and the enemy behaves similar as in the video. If there is currently no good solution to this problem, you could build the obstacle by combining shorter sloping elements, which will decrease the area that the enemy cannot move.

Yeah, I know, but doing it even for one isometric level would be an absolute nightmare (And most likely will affect the FPS). It’s a shame that GDevelop literally allows you to create something as complex as classic isometric RPG systems without a single line of code, but this little flaw/technical limitation just makes it impossible. Giving up isometry and switching to top-down is a huge loss to the art style of my game. :upside_down_face:

I wouldn’t give up so quickly on that. Did you try to add your obstacle sprite horizontally to the scene, cropped to the actual pixels? If you rotate it in the editor, the pathfinding is still weird but not as bad as before. Doing that might bring up other problems with the sprites though (especially if you use pixel art).
I just want to say that there is maybe a workaround.

It seems like you’ve mentioned the only possible variant in your previous message.

But yes, this is really only a workaround, not a legit method at all, doing this like so will add up big amounts of tedious work, probably some performance issues and bugs. Also, walls need to be quite thin for this to work, which might be another problem/limitation.

You could just add the thin walls as collider on top of your map and hide them - in case you see limitations with your art.

From that video, it looks like your player is possibly too close to the pathfinding obstacle for the enemy to get to the player. I’d suggest reducing the virtual cell size in the pathfinding settings on your enemy object. I’ve had similar issues in with pathfinding, and that solved it for me.

1 Like