Fast Moving Collision + TileMap "multi-hit" issues

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Takanu Kyriako
:warning: Old Version Published before Godot 3 was released.

I’ve been trying to develop a pinball-like game prototype, using the TileMap system as a way to draft out boards and I’ve come into an issue whereby when the pinball moves too fast and collides with the TileMap walls, it will sometimes register multiple hits from more than one tile and at different angles.

As the main wall tiles in my kit have the collision shape of a square, when the pinball moves even moderately fast and manages to hit near or on the border between two tiles, it’s getting hit normals from the side and corner of one of the collision squares when I just want it to only ever hit the exposed surface of the wall.

I have tried…

  • Increasing the Physics Fixed Timer (helped moderately by making it 120, but it doesn’t seem to get much more reliable at a much higher timer)
  • Using the Segment CollisionShape. Instead of the above the pinball just freaks out.
  • Tweaking the Solver Bias
  • Trying to use One-Way Collision
  • Use Continuous Collision Detection, both types
  • Changing the shape of the CollisionPolygon to prevent the pinball from reflecting off the side of the tile when not exposed - but as it still hits the corner of the adjacent tile this made no difference

Is there any way I can automatically merge the surfaces to prevent this instance, or would a custom collision solver be able to help this in any way that makes the result 100% reliable? I can hand-craft the collision bounds if need be, but especially for having to trace over curved walls accurately id rather a different solution.

If you get multiple hits at different angles for a single collision on a wall, I think that would be a bug in Godot. Does the ball moves correctly besides that?

Zylann | 2016-10-14 22:47

I have the same problem on 3.0.6 (also on 3.1 even with the new TileMap/TileSet system).

I have a very simple scene with a floor made of tiles with StaticBody & Rectangle shapes plus a “ball” with RigidBody & Circle shape and bounce of 1. You start the scene, the ball drops (gravity), hits the floor and often collides with many tiles – sometimes hits a tile corner, and bounces oddly off instead of just bounce up as you would think.

I get the feeling this is not a bug per se, it just is a technical incompatibility with tile-based collisions & rigid bodies?

Anaxagor | 2018-10-12 14:32

:bust_in_silhouette: Reply From: eons

If the ball goes too fast against a wall, soft curves wont matter much, you can try adding a layer of static blocks on the problematic parts and make the ball add this layer to the mask when reaches a specific speed.

Sorry for not responding sooner, but this was a good solution - i bumped up the static physics fps and kept some tiles that don’t have physics so I can just put solid blocks there instead.

Takanu Kyriako | 2016-11-20 04:54

@Takanu Kyriako - thanks for your comment (this saved me a lot of time!). I was having an issue with fast moving sprites not colliding with my tilemap and by changing the physics fps in settings (I went with 120), I am now getting collisions being registered.

Mison | 2021-05-09 18:31