to make character controller jump..help!!!

Hi,

I am working on a project in which i have to make a character to move continuesly in one direction . The Game demand is as long as the user touch the button the character shud make a jump. To do so instead of GUI button I am using GUI texture. But there is some problem in synchronizing between jump and speed .

My code is :-

private var controller : CharacterController;
var speed: float;

var jumpspeed: float=2;
private var moveDirection = Vector3.zero;

private var startTime: float;
private var endTime: float;

private var flag : boolean;

 var factor : float;


var texture1 : GameObject;

 

function Start()
{	
	controller=koala.GetComponent(CharacterController);
	flag=false;
}

function FixedUpdate ()
 {


	
	speed+=factor;

	if(controller.isGrounded)
	{

	}
	
	else
	{
		
	moveDirection.y-=3*Time.deltaTime;	
	}

      moveDirection=Vector3.left;

	moveDirection.y-=3*Time.deltaTime;	
	
		
	controller.Move(moveDirection*speed*Time.deltaTime);	

	print(speed);


}

function Update()
{
	
	
	for(var touch : Touch in Input.touches)
	{		
	
	 if(touch.phase==TouchPhase.Began  )
		{
		
		if(texture1.guiTexture.HitTest(touch.position))
			{			
			if(controller.isGrounded)
			{
				flag=false;	
			}

		 startTime=Time.time;
		
		}

	
	}//end of began
	
if((touch.phase==TouchPhase.Moved  texture1.guiTexture.HitTest(touch.position))||(touch.phase==TouchPhase.Stationary  texture1.guiTexture.HitTest(touch.position)))
	
	{	
			
		endTime= Time.time;		
		if(endTime-startTime<0.2    flag==false  )
			{	
			jumpspeed=jumpspeed+.05;
	   		moveDirection.y=jumpspeed;		
	  		moveDirection.x=speed;
	
	  		controller.Move(moveDirection*Time.deltaTime);
			}
			
			
	   }
		
	
	if(touch.phase==TouchPhase.Ended)
	{
		
	jumpspeed=2;			
	
	
	}
	
	}
	
}

Please Help!!!

The first problem I can see is that you are referring to a variable called “koala” when that isn’t defined. Is this just something you’ve introduced by copying/pasting to the forum or are you getting an error message for it in Unity?