Trigger And Jump

Hi all,

I’m making a script where my player to move alone and to give the jump button to jump, this all works fine, but when wanting to collide with an object to jump just I have not trouble the player jumps.

Here is the code I am and hopefully I can help, of course thank you very much.

#pragma strict

var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;

var velocidadRotacion = 3.0;

private var moveDirection : Vector3 = Vector3.zero;

function Update() {
    var controller : CharacterController = GetComponent(CharacterController); //Activa el controlador del personaje
   
     if (controller.isGrounded) { 
        moveDirection = Vector3(-1, 0, 0);
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
        if (Input.GetButton ("Jump")) {
        	 Jump();
            //moveDirection.y = jumpSpeed; //aplica un movimiento en y para saltar
        
        }
 
        transform.Rotate(0,Input.GetAxis("Mouse X")*Time.deltaTime * velocidadRotacion,0); 
    }

    
    moveDirection.y -= gravity * Time.deltaTime; 
    
    
    controller.Move(moveDirection * Time.deltaTime); 
}
function Jump(){
moveDirection.y = jumpSpeed;
}
function OnTriggerEnter(other: Collider){
  if (other.tag == "impulsor"){  		
  		 Jump ();
}
}

thank

What I get is this, at the time of the character to be in the air and hit the skip object but when the character is on the floor and hits the object this does not jump.

The only thing that would be missing is that jump when you touch the object and not solocuando is in the air.

I put the code here, Thanks

#pragma strict

var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;

var velocidadRotacion = 3.0;

private var moveDirection : Vector3 = Vector3.zero;

function Update() {
    var controller : CharacterController = GetComponent(CharacterController); 
   
     if (controller.isGrounded) { 
        moveDirection = Vector3(-1, 0, 0);
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
        if (Input.GetButton ("Jump")) {
        	 Jump();
           
        
        }
         
    }
 
    
    moveDirection.y -= gravity * Time.deltaTime; 
    
    controller.Move(moveDirection * Time.deltaTime); 
}
function Jump(){
moveDirection.y = jumpSpeed;
}
function OnTriggerEnter(other: Collider){
  if (other.tag == "impulsor"){
  		var controller : CharacterController = GetComponent(CharacterController); 
  		if (controller.isGrounded == true) {  		
  		
  			Jump();
  		}else{
  			Jump();
  		}
  		 
}
}