build problems

Hey,

I got some weird problems when i build my game.

I use a box collider as trigger and when my character is in the trigger and I press on the spacebar I want to do something.

function OnTriggerStay(collider:Collider)
{
   if(Input.GetKey("space"))
   {
      ......
   }
}

The problem is when i just run it in unity (not build) its working fine always. But when i build the program and run it then, then its not working all the time. Sometimes i need to press the spacebar 20 times before the game continues.

I got this problem with all my key inputs inside a trigger.

Anyone know what the problem could be?

Thanks.

Assuming you’re actually using GetKeyDown rather than GetKey, that’s because GetKeyDown returns true only during the one frame it actually happens, which may or may not be during a physics frame. The faster the framerate, the less likely that is. So you should put input code like that in Update, rather than FixedUpdate or any related physics functions (like OnTriggerStay).

–Eric