Button doesnt respond?!

hi,

im working on a simple jumpNrun testscene.
weird thing is, jumping (Arrow UP) works perfectly in the editor and webplayer but not on the standalone exe.
works/ doesnt work with joystick too.

Webplayer works:
deletedurl

standalone exe doesnt work:
deletedurl

my code:

var BUTTON_LEFT = false;
var BUTTON_RIGHT= false;
var BUTTON_JUMP= false;
var BUTTON_JUMP_DOWN= false;

private var jumping=450.0;
var collieded=0;
function Update () {

if (Input.GetKey(KeyCode.LeftArrow) || Input.GetAxis("Horizontal") < -0.5 ) {
BUTTON_LEFT = true;
}else{
BUTTON_LEFT = false;
}

if (Input.GetKey(KeyCode.RightArrow) || Input.GetAxis("Horizontal") > 0.5 ) {
BUTTON_RIGHT= true;
}else{
BUTTON_RIGHT = false;
}

if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.Joystick1Button0)) {
BUTTON_JUMP= true;
}else{
BUTTON_JUMP = false;
}

if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.Joystick1Button0)) {
BUTTON_JUMP_DOWN= true;
}else{
BUTTON_JUMP_DOWN = false;
}
//Buttons
///////////////////////////////////////////////////////////////  

}



function FixedUpdate () {
   rigidbody.AddForce (0, -35, 0);
   rigidbody.angularDrag = 100;
   
   if (BUTTON_LEFT) {
    rigidbody.angularDrag = 0;
   rigidbody.AddTorque(0, 0,30);
   rigidbody.AddForce (-7, 0, 0);
   }
      if (BUTTON_RIGHT) {
	   rigidbody.angularDrag = 0;
   rigidbody.AddTorque(0, 0,-30);
     rigidbody.AddForce (7, 0, 0);
   }
   
   
   if (collieded==0) {
      if (BUTTON_LEFT) {
    rigidbody.angularDrag = 0;
   rigidbody.AddTorque(0, 0,30);
   rigidbody.AddForce (-30, 0, 0);
   }
      if (BUTTON_RIGHT) {
	   rigidbody.angularDrag = 0;
   rigidbody.AddTorque(0, 0,-30);
     rigidbody.AddForce (30, 0, 0);
   }
   }
   
     if (BUTTON_JUMP_DOWN) {
	 	jumping = 450;
	 }
   
    if (BUTTON_JUMP) {
	jumping = jumping-40;
	if (jumping <= 0) { 
	jumping = 0;
	}
	rigidbody.AddForce (0,jumping, 0);
	}
   
}


function OnCollisionStay() {
collieded=1;
}

function OnCollisionExit() {
collieded=0;
}

In the web player, you can jump even if you aren’t touching the ground, just a possible bug. I can’t test out the executable because I’m on a Mac.

yeah endless jumping is OK

OK, so lets get your code down to something that looks easier to read. Lets start by getting rid of all your “button down” stuff. None of that is necessary. We can do all of this in the FixedUpdate since it all deals with forces.

var jumpForce=450.0;

funciton Start(){
	if(!rigidbody)
		gameObject.AddComponent("Rigidbody");
	rigidbody.angularDrag = 100;
}

function FixedUpdate () {
	// add gravity
	rigidbody.AddForce (0, -35, 0);
	
	// get controls
	var isGrounded = Physics.Raycast(transform.position, -Vector3.up, 0.6);
	var jump = Mathf.Clamp01(Input.GetAxisRaw("Vertical"));
	
	// setup bare forces
	var torque=Vector3(0,0,Input.GetAxis("Horizontal"));
	var force=Vector3(Input.GetAxis("Horizontal"),0,0);
	
	// check for forces according to if we are on the ground or not.
	if(isGrounded){
		torque*=30;
		force*=30;
		force.y=jump * jumpForce;
	} else {
		torque*=30;
		force*=7;
	}
	
	// apply forces if needed.
	if(torque.magnitude > 0.0) rigidbody.AddTorque(torque);
	if(force.magnitude > 0.0) rigidbody.AddForce (force);
}

You will see I am doing a Physics.Raycast check from the object, downward. If I see something, we are on the ground, if not, we are not. So this gets rid of the collision stuff you had before.

Also, I had corrected the logic so that if we are not on the ground, we are not jumping.

I dumped all the arrow stuff, and am solely using Input.GetAxis and Input.GetAxisRaw to get if we pressed buttons. This is because the arrows and WASD keys are all part of GetAxis and GetAxisRaw. (GetAxisRaw is -1, 0 or 1 thus eliminating the >0.5 stuff you had.)

next, I am using Math to calculate the force and torque. I know that if you are not on the ground, your force is less, so I added the multipliers in the right places to get your actual force. I also added the jump factor, but only in the section where we are grounded.

I hope this helps you out.

thx for answers.

solution:
if (BUTTON_JUMP_DOWN) {
jumping = 450;
}
should be in Update()