Spider like movement on a 2D, square terrain

I’m trying to simulate a spider walking along the edges of a 2D (square) tilemap and am running into a few issues, especially so when turning upside down.

I’m using the theory behind this solution: Blogs recent news | Game Developer

This works very well for their terrain layout, but moving along just the four cardinal directions is trickier than I anticipated! I managed to get the spider walking along the top, right and left directions, but when going upside down the numbers start going rather crazy.

Has anyone else managed to achieve something similar?

Some code would be good to check from you as this is the “scripting” forum :wink:

True that, but I figured as my solution is more or less identical to the link I posted I didn’t feel like it was necessary :slight_smile:

If anything, I was hoping to see if someone could point me in the direction of a better solution.

As I didn’t recieve much input on this I instead opted for a more hard-coded solution, using a combination of raycasts and determining what side of the wall to be on based on the direction of the movement. Not ideal, but it works.

I am using the same link you posted to make a spider movement for a platformer having some struggles, would you share your code? maybe i can pinpoint my problem then