So, i'm making a platformer game where there are enemies who switches sides whenever it hits a wall, the AI works fine when put on a solid platform like this
but, when put on spikes like this, the AI seem to be broken. The enemy would continue walking in the same direction, even when it hits a wall. So it would be stuck in one place
Here is the programming on my enemy
The walls are made of a solid tilemap while the spikes are solid sprites with a triangular hitbox. Changing the spikes' hitbox to rectangular doesn't work. What could be the problem?