Raycast2d not colliding with tiles

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

Hello,

I’m using Raycast2d, and the “is_colliding()” method isn’t working with my tiles.
( I followed this tutorial to make my tileset : http://docs.godotengine.org/en/stable/learning/features/2d/using_tilemaps.html )
It constatly returns me false.

However, the method does work fine when I make a replica of a tile directly in the scene, which led me to think that both the raycast and the tiles themselves are ok.
(a tile in this case being a sprite containing a staticBody2D, containing a rectangular collision shape)

Also, the collisions between my kinematic2D character and the tiles are working too.

Am I missing something or should I report this as a bug ?

Thank you in avance.

PS : I am using Godot_v2.1.1-stable_win64

I opened an issue : https://github.com/godotengine/godot/issues/9923

Bastien Creutzer | 2017-07-27 16:51

:bust_in_silhouette: Reply From: RandomShaper

Try with the 2.1.4 beta. Several fixes for physics have been made on that release.

Also make sure you are querying the ray after the engine has got the chance of updating its state; namely, at least a fixed frame has run since it has been created or by calling force_update() (or something similar, check the docs for the exact name) on it before checking.

I just tried with 2.1.4 and ended up with the same results.

The issue is not about the update either : it keeps on returning false when the raycast isn’t modified for multiple seconds, and the test with the replica in the scene does give the right result.

Thank you for your time.

Bastien Creutzer | 2017-07-26 23:04

I think I understand your issue better now. Indeed, it’s weird. Feel free to open an issue. Much better with a minimal example that reproduces the problem.

RandomShaper | 2017-07-27 08:33

:bust_in_silhouette: Reply From: Bastien Creutzer

The problem was that I didn’t didn’t modify the collision layers of the TileMap to match those of the tile and the collision mask the Raycast2D.