Hi, I’m trying to make an object randomly move in a maze in 2d I heard about raycasting but I do not know how to use this. I did find out that you can add some raycast components to an object, but I do not know what they do. I also found some tutorials about it, but when I try to follow them I get errors. Can someone please tell me how to use raycasting in this way?
You could just raycast against colliders (your walls, for example) and use that data to move your whatever is required to move. See the documentation:
Basically you just shoot a ray from your position to some direction. So you could cast a ray to left from an enemy character, and see if there’s empty space and what the available distance is. Then make that character move until it reaches that location.