Help with Enemy AI

So i made a basic “feeler” enemy AI that is only 2d which means it doesnt go up or down on the y axis. But now i would like to make it be able to walk up stairs or a ramp by felling around. Can anyone point me in the right direction on this? The 2d script im using now is:

var moveSpeed = 3;
var rotateSpeed = 10;
var checkDistance = 3;

var rightCheck : Transform;
var enemyChecker : Transform;
var leftCheck : Transform;

@HideInInspector
var target : Transform;
@HideInInspector
var controller : CharacterController;




function Start ()
{
	target = GameObject.FindWithTag("Player").transform;
	
	controller = GetComponent(CharacterController);
}

function Update () 
{	
	enemyChecker.transform.LookAt(target);
	enemyChecker.transform.rotation.x = 0;
	enemyChecker.transform.rotation.z = 0;
	
	
	
	var hit : RaycastHit;
	
	
	if (!Physics.Raycast(enemyChecker.transform.position, enemyChecker.transform.forward, hit, checkDistance))
	{
		transform.rotation = Quaternion.RotateTowards(transform.rotation, enemyChecker.transform.rotation, rotateSpeed/2);
	}
	
	if (Physics.Raycast(leftCheck.transform.position, leftCheck.transform.forward, hit, checkDistance))
	{
		transform.Rotate(Vector3.up * rotateSpeed);
	}
	
	if (Physics.Raycast(rightCheck.transform.position, rightCheck.transform.forward, hit, checkDistance))
	{
		transform.Rotate(Vector3.up * -rotateSpeed);
	}
	
	if (Physics.Raycast(leftCheck.transform.position, leftCheck.transform.forward, hit, checkDistance) && Physics.Raycast(rightCheck.transform.position, rightCheck.transform.forward, hit, checkDistance))
	{
		transform.Rotate(Vector3.up * rotateSpeed);
	}
	
	
	controller.SimpleMove(transform.forward * moveSpeed);
	
}

@script RequireComponent(CharacterController)

Can anyone point me in the right direction? Thanks!

Two ways

  1. You make the stairs small enough so that the CC can “climb up” → not so good though is it?
  2. You remove the colliders from the stairs and create a slope collider of one box collider inclined → good point, it looks the same and your player walks fine on it. You can have a basic check to mak him play a walkingUpTheStairs animation despite the fact he is walking a flat slope. Bad point, you have to remove all colliders from your steps…