Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are AutoTile collision shapes different from other collision shapes? #24300

Closed
ondrowan opened this issue Dec 12, 2018 · 4 comments
Closed

Are AutoTile collision shapes different from other collision shapes? #24300

ondrowan opened this issue Dec 12, 2018 · 4 comments

Comments

@ondrowan
Copy link

Godot version: 3.0, 3.1 alpha 3

OS/device including version: Windows 10, MacOS

Issue description & steps to reproduce:

I've tried to ask on reddit without any answer, so I'm not sure whether this is a bug or a feature. Either way, it's something that doesn't seem to be documented anywhere.

I'm working with simple sprite exported as TileSet. In a blank scene I'm trying to find collisions between a TileMap and a RayCast2D.


Autotile and RayCast2D don't collide in this case

From what I've tried collisions seem to behave differently when using Autotile. If I don't set any CollisionShape2D in TileSet scene, set TileSet as Autotile, set collisions on it via Autotiles menu and try to find collision with RayCast2D it works only if it intersects walls of the tile. If I move RayCast2D fully inside of the tile, it doesn't collide with it at all.


Autotile and RayCast2D do collide in this case

If I use the TileSet with static bodies and their own collison shapes, RayCast2D doesn't have problems with collisions even if it's fully inside of the tile.


TileMapStatic and RayCast2D do collide properly

I'm using default collision layers and masks on both TileMaps and on RayCast2D, so that shouldn't be the problem. I'm confused, because even when I set collision shapes to be visible in debug menu they are in both cases shown as full rectangles, but they don't seem to behave in the same way. Are collisions on Autotiles somehow special or am I just doing something wrong?

Minimal reproduction project: https://github.com/ondrowan/godot-autotile-raycast (requires 3.1 alpha)

@MarianoGnu
Copy link
Contributor

Afaik, raycasts have a feature to set what type of bodyes it collides with (rigid, kinematic and/or static). By default TileMaps are of type static, but there's an option on the properties to change it's body type to Kinematic, try to play with these values and tell me if you discoversomething.

By the other hand, tileset used to support all kinds of collision shapes. For the sake of simplicity, it now supports Convex polygon shapes, maybe there's an issue betwheen this kind of shapes and Raycast2D, not directly related to TileSet itself.

@ondrowan
Copy link
Author

@MarianoGnu I've set RayCast2D to collide with both areas and bodies, and tried it on a StaticBody2D with various collision shapes:

  • Capsule - raycast collides both when it intersects and when it's fully inside of the shape
  • Circle - raycast collides only when it intersects the shape
  • Concave polygon - I wasn't able to test this as it throws error with yesterday's nightly:
servers/physics_2d/physics_2d_server_sw.cpp:155 - Condition ' !shape->is_configured() ' is true. returned: Variant()
  • Convex polygon - raycast collides only when it intersects the shape
  • Rectangle - raycast collides both when it intersects and when it's fully inside of the shape

I didn't test segment, raycast and line shapes as RayCast2D cannot be put fully inside of them.

If it's supposed to work like this, there should be documentation describing these various shapes and why they are different. I also think there's UX issue where all these collision shapes are the same filled color (in debug mode with visible collision shapes) even though they work differently. To me as a beginner to game development, this caused a lot of confusion.

@MarianoGnu
Copy link
Contributor

shapes on tilesets are convex polygons

@KoBeWi
Copy link
Member

KoBeWi commented Jun 28, 2020

Sooo I inspected the reproduction project and the tilesets have different colliders. No idea how, the right one has RectangleShape2D, so it indeed behaves differently, but it's not TileSet-related issue. When you create a new collider using the new rectangle tool
image
it creates ConvexPolygonShape2D correctly like in the other TileSet, which works consistently with the other.

That said, you won't run into this bug when you make tilesets with the tileset editor. Also different shapes behaving differently with raycast is another issue (probably one of #39876).

@KoBeWi KoBeWi closed this as completed Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants