Hi all,

I've had to have a break for a few months due to work etc but I'm back and into my latest game.

I'm trying to achieve a Lemmings type of NPC.

They walk well

They fall well

They climb well

The problem is, sometimes they go crazy. Images attached:

See the end of this short GIF to see the problem:

Link to GIF as I can not figure out how to embed it here sorry

and another GIF showing another example

The full code is below, the idea is this:

Kinematic2D Character

Forward raycast attached to check for walls / objects in front

Floor raycast attached to check for floor

They always try and walk right

Once alive and instanced:

WALK STATE

start walking

If floor ray contact, walk

ELSE, fall

If forward ray contact, climb

RUN STATE

start running

If floor ray contact, run

ELSE, fall

If forward ray contact, climb

FALL STATE

start falling

if floor ray contact, run

ELSE, fall

CLIMB STATE

start climbing

if forward ray contact, run

The code didn't show up here properly so have added a link to it here

Can anyone offer any advice as to why they're doing that? Thanks so much