Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Script not working

Discussion in 'Scripting' started by TheWgames, Sep 1, 2013.

  1. TheWgames

    TheWgames

    Joined:
    Nov 29, 2012
    Posts:
    27
    I made this script, and it doesn't work.
    Could somebody tell me what is wrong with this script?

    function OnCollisionEnter(other: Collision){

    if (other.gameObject.name == "C1"){

    Application.LoadLevel("PC_2");


    }

    }

    Thanks,
    Willie
     
  2. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    680
    looks fine.. i suppose you are not getting any error msg?
     
  3. TheWgames

    TheWgames

    Joined:
    Nov 29, 2012
    Posts:
    27
    no not any.
     
  4. Fyko-chan

    Fyko-chan

    Joined:
    Sep 29, 2012
    Posts:
    76
    My guess is that the name is not "C1", try with tags and see if that works?
     
  5. TheWgames

    TheWgames

    Joined:
    Nov 29, 2012
    Posts:
    27
    No, it didn't work.
    What are the things I need to add to the objects?
    Maybe I forgot something there.
     
  6. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    Do you have a collider and ridgidbody components attacted to the object, maybe try adding a Debug.log statement to the oncollisionEnter function and one after the if statement and see if they are occuring...