4ian / GDevelop

🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone.
https://gdevelop.io
Other
11.18k stars 864 forks source link

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

Open Evil-Mastermind opened 3 years ago

Evil-Mastermind commented 3 years ago

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

Silver-Streak commented 3 years ago

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.

tristanbob commented 3 years ago

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

krunkster commented 3 years ago

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

tristanbob commented 3 years ago

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!

D8H commented 3 years ago

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 commented 9 months ago

The NavMesh extension allows to workaround this issue.

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

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