Hello UnityAnswers- I need help figuring and setting this up. Here is the situation- I would like to set, store/recall creatures with buttons that are automatically assigned to them when I allow them in my party.
I have no idea on how to set this properly, so I'll attempt something we can start on...I know it's lame, but it's all I understand to tackle this yet :(
On Beasts speech
Long story short--
- Creature asks to join your party..
- You say yes/no
-
if you say yes:
do something like ( `Hero.Beast *= gameObject;` ) ???
*
*
On Hero's script
* *```* *static var Beast : GameObject [];* *function OnGUI(){* *var LineupInt : int = -1;* *var LineupStrings : String[] = ["Beast1", "Beast2", "Beast3"];* *LineupInt = GUI.Toolbar (Rect (25, 25, 250, 30), LineupInt, LineupStrings);* *if(LineupInt == 0) // press Button1* *if (Beast.length > 0){* *if(Beast[1] != null)* *Beast[1].SetActiveRecursively(false);* *else if(Beast[1] == null)* *Best[1].SetActiveRecursively(true);* *}* *if(LineupInt == 1) // press Button2* *if (Beast.length > 0){* *if(Beast[2] != null)* *Beast[2].SetActiveRecursively(false);* *else if(Beast[2] == null)* *Best[2].SetActiveRecursively(true);* *}* *etc* *```* *So, how do I tell the Hero's script Beast[] string to assign someone to the next available number, then reference them again specifically with the buttons?
* *Thanks for any help! ( ps- how bad is my attempt too? I'M TRYING! :)
* *EDIT: My answer
* *Okay, here is the set up:
* *in the dialogue script, if you accept the offer to join your team, I said this
* *Hero.Beast.Push (gameObject); to add to the array
* *in the Hero's script I put this
* *```* *static var Beast = new Array();* *var beast1 = false;* *var beast2 = false;* *var beast3 = false;* *var beast4 = false;* *function OnGUI () {* *var LineupInt : int = -1;* *var LineupStrings : String[] = ["Beast1", "Beast2", "Beast3"];* *LineupInt = GUI.Toolbar (Rect (25, 25, 250, 30), LineupInt, LineupStrings);* *// Beast ONE* *if (LineupInt ==0)* *if(Beast[0] != null){* *print(Beast[0]);* _//** The first is set at the start of the level- will edit later **_ *// Beast TWO* *}if(LineupInt ==1)* *if(!beast2)* *if(Beast[1] != null) {* *print("Beast 2 is stored");* *LineupStrings[1].name = Beast[1].name; //(???) see comment* _Beast[1].transform.position = transform.position + transform.right * -4 + transform.up *7;_ *Beast[1].transform.parent = transform;* *Beast[1].SetActiveRecursively(false);* *LineupInt = -1;* *beast2 = true;* *}if(LineupInt ==1)* *if(beast2){* *print("Beast 2 is released");* *Beast[1].SetActiveRecursively(true);* *Beast[1].transform.parent = null;* *LineupInt = -1;* *beast2 = false;* *//And so on and so forth for each button in the toolbar* *```*