Check if there is a wall between two sprites

Hi … is there a possibility to understand if there is an object between two sprites ?


For example : if the soldier (player1) is under the wall, the ninja can’t see him.
For the moment, i use “distance between two objects” to activate the ninja, so he attacks the soldier when they are close. But i’d like to introduce this condition.
Thank you!

You should use the raycast feature, see the example bundle with GD for understand how it works. There is also an artcile about raycast on the wiki.


ok, thank you @Bouh!

i do in this way :

Can the ray stopped when it collide with the wall ? So, the enemy can’t see the player1 if he is behind the wall.
thank you! :slight_smile:

P.S. Where is “example bundle with GD” for raycast ? i don’t find it.

Here Zombie lazer example