GDevelop icon indicating copy to clipboard operation
GDevelop copied to clipboard

Pathfinding obstacle uses the entire bounding box, not just the collision mask

Open Evil-Mastermind opened this issue 3 years ago • 6 comments

Describe the bug

If you set up a sprite obstacle and a simple move to click location event on a character, the character refuses to pass through the area of the entire bounding box, not just the collision mask.

(Game where bug occurred linked at bottom)

To Reproduce

  1. Create a character with a move to clicked location pathfinding style of movement. image

  2. Create a pathfinding obstacle that does not fill the entire area of the bounding box with the collision mask. image

  3. If the main character starts within the bounding box of the obstacle but outside of its collision mask, the character refuses to move.

  4. Having the character outside and clicking to go through the non-collision area of the sprite causes the character to move along the bounding box.

Other details

  • GDevelop 5.0.0-beta110 based on GDevelop.js 4.0.99-0-release
  • Desktop app on Windows 10 Education edition
  • The game where this bug occurred (WASD movement is for debug purposes, which is why the top "Move away" event at the top. The player can move through the middle lane with WASD, but clicking anywhere inside the bounding boxes of the obstacles does not generate a path. For this purpose, there is a second instance of the MainCharacter who is placed outside the bounding boxes to quickly compare pathfinding behavior.)

Evil-Mastermind avatar May 29 '21 14:05 Evil-Mastermind

I wasn't able to reproduce this at first, but I can now confirm this.

The pathfinding obstacle behavior seems to ignore all collision mask modifications and any rotation.

Here's a simple scene set up, the stretched crate is rotated from it's normal position, and is an impassible pathfinding obstacle.

image

Here's what happens when I click above the box. It goes around an invisible wall (prescisely where the boundary box is), then goes through the sprite. image

https://game-previews.gdevelop-app.com/1622301720948-354654/index.html If you'd like to test for yourself.

Silver-Streak avatar May 29 '21 15:05 Silver-Streak

I am seeing a similar problem with Physics collisions on sprites that are rotated and have increased width. I can create a new issue if these problems are not related.

I am using the default Physics collision settings for the "static" blocks, and the balls are using the "circle" shape with a correct radius (30 pixels).

https://twitter.com/VictrisGames/status/1398865857955074052

https://user-images.githubusercontent.com/8879811/120092774-ca062e80-c0d2-11eb-9f96-1b52cd718fc6.mp4

tristanbob avatar May 30 '21 05:05 tristanbob

I've found that when you stretch a Physics2 object you need to invoke "Shape Scale" to update the collision mask.

krunkster avatar Jun 08 '21 20:06 krunkster

I've found that when you stretch a Physics2 object you need to invoke "Shape Scale" to update the collision mask.

How is this done? Is this an action for Physics objects? (Answer: YES)

Screenshot 2021-06-08 142047

I will try this and write back. Thanks!

tristanbob avatar Jun 08 '21 20:06 tristanbob

This PR allows to choose between 3 collision methods: legacy, hitbox and AABB. The hitbox method is what you are looking for. There is a GDevelop custom build to try it. https://github.com/4ian/GDevelop/pull/2284

D8H avatar Jun 09 '21 19:06 D8H

The NavMesh extension allows to workaround this issue.

  • https://wiki.gdevelop.io/gdevelop5/extensions/nav-mesh-pathfinding/

It uses a very old version of Recast tweaked for 2D.

  • https://github.com/recastnavigation/recastnavigation

We should probably wrap a more recent version using Emscripten like Babylon.js did:

  • https://github.com/BabylonJS/Extensions/tree/master/recastjs

D8H avatar Jan 23 '24 08:01 D8H