Fix Stair Bug With Code (please help, at last take a look)

Hello every body, as i said i have problem with stair…
and if u ask where , i say in going up, and again if you say define less height, i say i need them to be bigger…
so i write some code, but i got some problem, cuz i dunno when character move positive or move negative or for example when he go left or when he going right, cause all i have in input manager is ‘Vertical’ and ‘Horizontal’, Not ‘Forward’,‘Backward’,‘Left’ or ‘right’.

please take a look, and if you can complete the part is incomplete.

and one more thing, the tag stair is not bind with stair it self, but i also add 1 more horizontal object in front of each step, that character first will hit them, like this :

l_
  l_
    l_

think my stair is like this, and the tag is bind to i, now think i is the layer in front of my each step like this:

li_
   li_
     li_
        li_

here’s my incomplete code…

var target:GameObject;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
	if (!target) target=hit.gameObject;
	if (target.name!=hit.gameObject.name)
	{
		if (hit.gameObject.tag=="Stair")
		{
			target=hit.gameObject;
			//Codes Here
			if (Input.GetButtonDown=="Vertical")
			{
				var forward=transform.forward;
				var targetDir=hit.transform.position-transform.position;
				var angle=Vector3.Angle(forward,targetDir);
				if (angle<179)
				{
					//if character vertical move is positive Move Target a bit forward and Up
				}
				if (angle>181)
				{
					//if character vertical move is not positive Move Target a bit backward and Up
				}
			}
		}
	}
}

[/code]

i tried to change code my self, but even my object don’t move :cry: just if i put debug.log, it type the note

ok,
i come up with some thing, and at last functionality work, but still need help …

//private 
var target:GameObject;
var stairHeight=0.5;
var moveForward=0.1;
var functionNum:int=0;

function OnControllerColliderHit(hit : ControllerColliderHit)
{
	if (!target) target=hit.gameObject;
	if (target.name!=hit.gameObject.name)
	{
		if (hit.gameObject.tag=="Stair")
		{
			target=hit.gameObject;
			//Codes Here
			if (Input.GetButton("Vertical"))
			{
				var forward=transform.forward;
				var targetDir=hit.transform.position-transform.position;
				var angle=Vector3.Angle(forward,targetDir);
				if (angle<89)
				{
					functionNum=1;
					//if character vertical move is positive Move Target a bit forward and Up
				}
				else if (angle>91)
				{
					functionNum=2;
					//if character vertical move is not positive Move Target a bit backward and Up
				}
			}
			else if (Input.GetButton("Horizontal"))
			{
				var right=transform.right;
				var targetDirH=hit.transform.position-transform.position;
				var angleH=Vector3.Angle(right,targetDirH);
				if (angleH<89)
				{
					functionNum=3;
					//Right
					//if character vertical move is positive Move Target a bit forward and Up
				}
				else if (angleH>91)
				{
					functionNum=4;
					//Left
					//if character vertical move is not positive Move Target a bit backward and Up
				}
			}
		}
	}
}

function Update()
{
	Debug.Log(Input.GetAxis("Horizontal")+" " + Input.GetAxis("Vertical"));
	switch(functionNum)
	{
		case 1:
			transform.Translate(Vector3.up*stairHeight);
			transform.Translate(Vector3.forward*moveForward);
			functionNum=0;
			break;
		case 2:
			transform.Translate(Vector3.up*stairHeight);
			transform.Translate(Vector3.forward*-moveForward);
			functionNum=0;
			break;
		case 3:
			transform.Translate(Vector3.up*stairHeight);
			transform.Translate(Vector3.right*moveForward);
			functionNum=0;
			break;
		case 4:
			transform.Translate(Vector3.up*stairHeight);
			transform.Translate(Vector3.right*-moveForward);
			functionNum=0;
			break;
	}
}

[/code]

lol, still no response…
i really wonder if this forum gonna help any one …

in more than ?? thread, i just got 1 semi complete, and 1 incomplete answer …

My only thought is to litter your methods with Debug.Log calls and validate the values of all your variables each step of the way. (for example, is the angle returned from Vector3.Angle what you expect?)

Trace the values through and do the same calculations (on paper or mentally) and figure out where your code diverges from what you expect.

Muhahaha, i see an answer, but wrong answer, at last not one for what i asked, and in whole the time you answer this, i already made two or three more script with other method…
still have a little bug, but is much better.