Search Unity

Vehicle Hanger/ Character Inventory

Discussion in 'Scripting' started by Enuniq, Oct 22, 2013.

  1. Enuniq

    Enuniq

    Joined:
    Oct 17, 2013
    Posts:
    10
    Hey guys!

    Ok, so I'm not sure where to look, what it's called, or anything. If anyone of you know or play World of Tanks, it has hanger or garage where it stores different tanks. I'm curious how I could achieve the same result. Where you can choose from several different vehicles.
    I'm a slight noobie. :/

    Thanks,
    E
     
  2. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    Just place multiple tanks in a scene and then setup some kind of Tag system such as tank1, tank2, ect. Then you will need to create a raycast so when the player clicks on a tank it can then check the tag for which tank. From here you can have a variable that keeps track of which tank the player has selected and when the match starts you can just instantiate that specific tank.
     
  3. djfunkey

    djfunkey

    Joined:
    Jul 16, 2012
    Posts:
    201
    Just make a scene for the tanks to be viewed in, then you need to script...
    • Make an array and store the tanks in it.
    • Then using the GUI scripting, when a player presses a button (this button corresponds to a certain tank), a tank will be instantiated from the array and you need to delete the one that was previously there.
    • Set this tank as the default to use in your multi-player scene.
     
  4. Enuniq

    Enuniq

    Joined:
    Oct 17, 2013
    Posts:
    10
    Thanks, how exactly would I set it as the default. And, what if I wanted to have different tiers (unlock)? How would it know which tank the player bought? Thanks, I'm such a newbie, lol
     
  5. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
  6. djfunkey

    djfunkey

    Joined:
    Jul 16, 2012
    Posts:
    201
    Im assuming your writing your scripts in C#

    how exactly would I set it as the default?
    Well you could make a new variable gameobject. You would then equal the tank you selected to the gameobject variable. e.g.
    Code (csharp):
    1.  
    2. public Gameobject defaultTank;
    3. defaultTank = tankSelected;
    4.  
    what if I wanted to have different tiers (unlock)?
    Well then you could attach a script to each one of your tanks saying whether it is unlockable or not. Next search through each tank in your array to find if it is unlockable using ".GetComponent". if it is then let the player buy it.

    How would it know which tank the player bought?
    You could have a money script containing how much money you own.
    You would then subtract the tank amount, from the amount of money you have (if the tank is unloackable).
    You can make a new array list (containing tanks you have bought) and add each tank gameobject to it as you buy it.

    In any case you should knuckle down and get to learn the ins and outs of unity scripting :) have fun.
     
  7. Enuniq

    Enuniq

    Joined:
    Oct 17, 2013
    Posts:
    10
    Thanks a bunch guys!!!!!