Ok so I have a script that will change level on colliding with a certain object but I does not work.
Does anyone know how to fix it.
Here is the code:
var myLevel : String;
function OnCollisionEnter (myCollision : Collision) {
if(myCollision.gameObject.name == “Player”){
Application.LoadLevel(myLevel);
}
}
Use code tags when posting. Also always explain how does it not work, code error or nothing happens?
I guess you are missing colliders or etc.
Throw in a Debug statement beforehand, and check the name of the Collider gameobject. If you don’t get a statement at all, you arent detecting collisions. If you do, double check that the name is correct (careful when comparing strings directly in code, usually best to use String.Compare instead).