How to make "is_on_wall" ignore some walls

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yamz

I have an enemy and when it hits a wall it changes its direction, but it also happens with the player
I would like the clash with the player not to change the direction

How could I fix it

Script Enemy

 if is_on_wall():
    		direccion.x = 1 if direccion.x == -1 else -1

This question is much more clear and understandable than the other 2 mentioned. But you should avoid spamming anyway. Maybe editing would’ve been a better.

tastyshrimp | 2019-12-12 21:00

:bust_in_silhouette: Reply From: tastyshrimp

You could go through all the collisions and skip direction change if the player is the only colliding body.
There is an example of how to do it in the docs: KinematicBody2D — Godot Engine (3.1) documentation in English