- Home /
Question by
Zacharianinjaa · Aug 29, 2012 at 10:42 AM ·
javascriptcollisionrigidbody
Collsion without ririgibody
I need my player to collide with a trigger wall in order to load the next level. However i dont want to put the RigidBody on the player. is there any way around this?
this is my code:
function OnTriggerEnter (collision : Collider) {
if(collision.gameObject.name == "Player") {
Debug.Log("Loaded");
}
}
Comment
Answer by Piflik · Aug 29, 2012 at 11:06 AM
Put the rigidbody on the trigger. (One of the objects needs a rigidbody for a collision to work)
Alternatively: Use a simple distance check:
if(player.position - transform.position).sqrMagnitude < threshold
Application.LoadLevel("nextLevel");