Standalone jump different than Webplayer?

Hi guys,

Just started with Unity scripting and bumped into something frustrating.
I wanted to make a cube jump the moment you press ‘C’.

I based this script on an example from the Unity scripting documentation:


var jumpSpeed = 6.0;
var gravity = 20.0;

var moveDirection = Vector3.zero;

function FixedUpdate(){

var controller : CharacterController = GetComponent(CharacterController);

		//get c key to jump
	if(Input.GetKeyDown(KeyCode.C)){
	
		moveDirection.y = jumpSpeed;
		
		}
		//add gravity
	moveDirection.y -= gravity  * Time.deltaTime;
		//some debuginfo
	print(moveDirection);
		//the actual move based on above generated numbers
	controller.Move(moveDirection *Time.deltaTime);

}


Now, to me this looks like a fairly simple script. It works fine inside the Unity Preview, it works fine in the standard webplayer, it starts to get picky in the web player at fullscreen and it doesn’t react to ‘c’ button presses at all in the windows standalone.

Does anyone have any pointers on what can cause this behaviour?
thanks in advance,
Remi

PS:
Download the webplayer version here:

webplayer

And the .exe here:

Standalone exe

this is simply because you’re only checking for button input every nth frame. Depending on your quality settings, FixedUpdate can fire at completely different times.

put your input handling code in a normal Update, and ONLY put physics code inside FixedUpdate. That’s what it’s there for.

Hi there,

thanks for your answer, that really helped!

Only thing now is that I cannot move the "GetComponent" variable to the top of the file, into function Update() or into function Start(), the debug log than starts to protest with various arguments. Any idea what can cause this?