Hello.
The structure of the main scene:
- Node2D:
- - Player
- - Enemies:
- - - Enemy1
- - - Enemy2
The structure of the enemy scene (Enemy.tscn):
- KinematicBody2D:
- - Sprite
- - CollisionShape2D
Player - scene instance Player.tscn; Enemies - Node; Enemy1 and Enemy2 are instances of the Enemy.tscn scene;
The problem is that when the Player casts the ray using get_world_2d.direct_space_state.intersect_ray(coordinates1, coordinates2, [self])
, it passes through Enemy2 without touching it (but it hits Enemy1).
What is the problem here and how to solve it?