Miko colliding with wall, do Miko variable choice = RandomInRange(0,1)
if Miko Variable choice = 0, then Miko variable direction = 2
if Miko Variable choice = 1, then Miko variable direction = 3
This way when the character collides with a wall, it will decide if going up or down.
A more intuitive approach could be:
if Miko variable direction = 0
Miko don’t colliding with wall, press Right.
Miko colliding with wall, do Miko variable direction = 2
Normally we associate right and up, and left and down together.
Another way could be to test the possible paths for Miko and then choose one, or use special objects meant to tell Miko which paths are open so it can have a choice.
I would look at adding 4 points on the sprite, each a few pixels outside the sprite border. One for the top, bottom, left and right edges. When the player presses a direction key, check that the point for that direction isn’t on a wall object.
in my opinion raycasting would be a good way to do it like if raycast from player angle -90(this is up if I remember correctly) distance 8 would work in theory
You need to give more context what are you referring to when you say “both of them”?
It looks like you are using oscuridad666’s reply. I don’t think that exact answer would have solved the problem. Because when the player is in collision with the wall, it’s not being moved away, and so stays in collision with the wall.
Also, that random in range and then changing the direction value is not the best way to do it.