- Home /
Disable All Transform In List
Hello Everybody
i use List
//VAR
public List<WeaponInfo> WeaponList = new List<WeaponInfo>();
public WeaponInfo CurrentWeapon;
//CLass
[System.Serializable]
public class WeaponInfo{
public string name = "Weapon";
public Transform WeaponTransform;
}
//Set Weapon CurrentWeapon = WeaponList[0];
i want when The CurrentWeapon = WeaponList[0]
Then Disabled All other WeaponTransform except the WeaponTransform Of The Current Weapon
For Example I Have 3 Weapon
When CurrentWeapon = 0 Then Disable Transform Of Weapon 1 and 2
etc.
I suggest you to Destroy()
the objects that you aren't using and Instantiate()
the other ones when using these weapons. If you make it a child to your character after the object instantiation, the object will follow the character.
@FL its weapon, Sure it will follow the Character i need that :)
thanks anyway
Answer by whydoidoit · May 05, 2013 at 01:28 PM
Something like:
foreach(var weapon in WeaponList)
{
weapon.WeaponTransform.gameObject.SetActive(false);
}
CurrentWeapon.WeaponTransform.gameObject.SetActive(true);
Your answer
Follow this Question
Related Questions
Dynamic Enemy Transform List 1 Answer
Using lists or arrays of transforms in Boo. 1 Answer
Keep adding targets to a list 2 Answers
A node in a childnode? 1 Answer
How to draw text based on text above it? 0 Answers