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. Dismiss Notice

Help with C# code

Discussion in 'Scripting' started by sjoerdtim, Jun 13, 2014.

  1. sjoerdtim

    sjoerdtim

    Joined:
    Jun 13, 2014
    Posts:
    4
    Hello!
    I have recently started working with Unity, and I can't seem to get passed this part.

    http://pastebin.com/bPkJ6tkr

    It's supposed to end the game when you touch any Object with wall in it's name (aka, Left Wall, South Wall, Third Wall, all of the things similar to that.), but it keeps giving me errors I can not solve about the code.
    The moving part is working properly, and there's no errors on that side.

    It is probably a very stupid thing I missed, but I couldn't figure it out myself so figured I should ask the people here.
    Thanks for your reading/helping! :)
     
  2. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Your code looks perfectly fine. What are the error messages you're getting?
     
  3. sjoerdtim

    sjoerdtim

    Joined:
    Jun 13, 2014
    Posts:
    4
    Okay wow.. The errors just disappeared.
    Sadly though, the game still doesn't restart when I hit the objects "North, East, South & West Wall"
     
  4. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    Are your walls marked with a tag named "Wall"? And do you have your scene added to the "Scenes in build" section of the "Build Settings" dialog?
     
  5. sjoerdtim

    sjoerdtim

    Joined:
    Jun 13, 2014
    Posts:
    4
    How do I tag them and how do I add them to the scenes in build?
    I thought "contains" just checked if the title of the object contained those words.
     
  6. Landern

    Landern

    Joined:
    Dec 21, 2008
    Posts:
    354
    It does check to ensure it contains it, in your case it would be case-sensitive, you can add tags however by following the instructions here: http://docs.unity3d.com/Manual/class-TagManager.html

    Then adjust the tag through the inspector for the various walls(or just do it to the prefab).