AI Behavior?

So if you have ever played Krusty’s Super Fun House, you will notice that the “mice” walk back and forth between two “wall” colliders, and cant continue on because the next platform is two units too high, until the player places a block, representing a “step” up to the next platform. The Mouse can go up one unit and onto the block, then up another unit onto the next platform, but it cannot go up two units. SO my question is, how would I recreate this behavior in Unity. The patrolling isn’t a problem as that’s easy but how would I get the mouse to “step up” onto the block the player dropped in his path?

Well, in that case, I would not use different collision code for walls or blocks- what matters is the height relative to the player, not what kind of object it is.

I think the best way to get the ‘height’ relative to the player in this case would be by getting the collider’s bounds, then comparing it’s size & position to the agent position.

so you’d get something like

 if (Physics.Raycast(transform.position, fwd, out hit, 1) && !turn && !moveUp)
     {
         Debug.DrawRay(transform.position, fwd, Color.yellow, 1);
 
         if(hit.collider)
         {
            Bounds b = hit.collider.bounds;
            float heightDifference =  b.max.y - transform.position.y; 
            
            if(heightDifference < 1) moveUp = true;                   
            else turn = true;  
         }
}

if(turn){
//put turn code here
//be sure to put turn to false when it is completed

}
if(moveUp){
//move up code here
//again, put to false when movment is completed
}

if(!moveUp && !turn){
//normal move code here
}

moveUP and turn should never both be true at the same time I think, but I haven’t really checked. You may want to have some way of handling it if that somehow happens anyway.

(By the way, have you considered using Unity’s built-in navigation system instead? The “Step Height” option in a navigation mesh is pretty much exactly what you want. Depending on your game it may not be suitable though, just something to consider).