OnTriggerEnter (JS)

I have a script for an object. If the object hits my player it should load an other screen. The problem is, it only works when the player is moving. If the player doesn’t move the application doesn’t load.

Here is what I have:

function OnTriggerEnter(otherObj: Collider){

    	if (otherObj.tag == "Player"){ 
        	Application.LoadLevel("deathscreen");
        }
}

Hope you know what the problem is.

You’re probably using a CharacterController.

OnControllerColliderHit

If you want to use regular collision detection or trigger on a character it needs another collider component in addition to the charactercontroller, charactercontroller only detects collisions while moving. You could always attach a child collider to the controller and put your collision script on that child. If you’re using OnTriggerEnter, be sure one of the objects involved has a rigibody attached.