Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Trying to make Conditions

Discussion in 'Scripting' started by McKaygamer, Jan 25, 2015.

  1. McKaygamer

    McKaygamer

    Joined:
    Jan 25, 2015
    Posts:
    2
    Hey guys I need help. I'm trying to make a condition for my character where it's only able to get to a certain item if it has 2 items total in it's inventory. And also trying to have it go to a cut scene when the condition is fulfilled I have a Item collect script, Item script, .and inventory script and the end scene already made.
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Generally a count, int will do.
    Code (csharp):
    1.  
    2. //pick up item
    3. itemsOwned++;
    4.  
    5. if(itemsOwned == 2)
    6. conditionMet();
     
  3. McKaygamer

    McKaygamer

    Joined:
    Jan 25, 2015
    Posts:
    2
    Thanks. I need to figure out how to make a condition.
    What i'm going for is this:
    If the player has 2 items they can get to the item to finish the game.
    Have a text pop up saying that they got both items now finish the game.
    When they get to the item It will automatically trigger the end scene and fade out to the end credits.
    like I said I have the items made and the end scene made too.
    Thanks again:)
     
  4. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    So, are you asking something?