Help with side-scrolling platformer enemy behavior

So for a while now I’ve been trying to implement some simple AI behavior for a basic Goomba-type enemy such as having the enemy turn around and walk in the other direction when they hit a wall or reach the end of a ledge. To help myself out, I’ve been following this video here [Link] which uses collision boxes to fulfill both behaviors.

The problem is that I’m rather hesitant about using collision boxes, largely because in the past I tried using a collision box for my player character jumping on enemies and I ended up having issues with the collision box not being able to react fast enough. I’m not sure if I need to worry about that with just an enemy walking into a wall or not but I’d rather use line/box tracing instead as that’s what I used from the jump collision and it works perfectly.

Unfortunately, the video doesn’t explain how to use line/box tracing for this, although it does mention it. I tried modifying the jump collision logic in conjunction with the stuff shown in the video but I can’t get it work at all.

Can anyone please help me out with this?

Thanks in advance!

Can anyone please help me out, I have absolutely no idea on what I’m doing. :sob:

I just want to use a line trace to detect when an enemy reaches the end of a ledge and then have them turn around & go in the opposite direction but I just can’t seem to get it to work. It doesn’t help matters that tutorials on the subject seem to be virtually nonexistent.