Load Next Level on Collision with Wall
Using Oncollisionenter with js, the script does not work:
#pragma strict
function Start () {
}
function Update () {
}
function OnCollisionEnter (collision : Collision) {
if (collision.gameObject.name=="Player")
{
Application.LoadLevel("Level2");
Debug.Log("YAy");
}
}
Also, The YAy does not appear in the log. The name is correct The script is attached to the wall to which the player(FirstPersonController) must touch. The wall has a box collider PS: If anyone has an alternative, please post it, it would be greatly appreciated, c# is my preferred language.
Answer by Jessespike · Nov 20, 2015 at 08:45 PM
Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. Source: http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
So, just add a RigidBody to the Player GameObject, enabled IsKinematic and enable Trigger on the wall's collider.
Watch Unity Tutorials - Physics: Colliders As Triggers for more info
That does'nt seem to work, also now i simply walk through the wall...
Thanks, I checked the link, it now loads the next level but i pass through the wall
Your answer
Follow this Question
Related Questions
cannot be an iterator block because `void' is not an iterator interface type 1 Answer
Roll A Ball Beginner Tutorial in Android controls 1 Answer
Scripts Interfering With Each Other 1 Answer
UCE0001: ';' expected. Insert a semicolon at the end. 1 Answer
all compilers have to be fixed befor entering game mode .. 3 Answers