Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | wndr |
Hey. I have a set of 4 Raycasts coming out of my player’s body. They are all enabled and have their collision mask bit 0 set to true. I also have a TileMap with the same collision mask and layer bit set to true (bit 0). However, while my player collides with the TileMap properly, my raycasts don’t.
Raycast code:
func _check_is_valid_wall(raycasts):
for raycast in raycasts.get_children():
if raycast.is_colliding():
var angle = acos(Vector2.UP.dot(raycast.get_collision_normal()))
if dot > PI * 0.35 && PI * 0.55:
return true
return false
Additionally, on the TileMap, use_parent and use_kinematic are set to false, friction is set to 1 and bounce set to 0. I made the collision shapes by selecting a region of the tilesheet with New Single Tile, followed by creating a new collision rectangle. Every other value in the tile is set to their default.
EDIT:
I have a very strong feeling that this behavior happens because of how the engine makes the collision polys for the tiles. It’s actually just very thin (0-thickness) lines; For the purposes of one way collision and such. I believe that because of this, raycasts can pass through these walls if cast from close enough. Not sure though.
I’m also having an issue with raycast2d and tilesets
the get_children() method is throwing the error “Invalid call. Nonexistent function ‘get_children’ in base ‘Nil’”
is this true for you aswell?
rodan | 2020-03-06 13:56
No, I get no errors.
wndr | 2020-03-06 14:35
I fixed my earlier issue and am now experiencing the same thing you are. I’ll let you know if I figure anything out
rodan | 2020-03-06 15:24
Thanks. I’ll keep this thread updated with anything I find.
wndr | 2020-03-06 15:45