private void GenerateCharacter() { // Small catch for errors, should never reach this however if (!bGenerationSuccess) { Debug.Log("Error reached while generating character!"); return; } Debug.Log("No error found, have a nice day"); // Creates new gameobject in scene GameObject NewCharacter = new GameObject(newUnit_ID); // Creates a child object to house the model and its animations, but otherwise nonfunctional GameObject BaseModel = GameObject.Instantiate(newUnit_Model); BaseModel.transform.SetParent(NewCharacter.transform); // Creates NavAgent NewCharacter.AddComponent <NavMeshAgent>(); // Creates a weapon object GameObject WeaponBase; if (newUnit_HasWeapon) { // Once the weapon is created, set its parenting, position, etc WeaponBase = GameObject.Instantiate(newUnit_Weapon.gameObject); WeaponBase.transform.SetParent(NewCharacter.transform); WeaponBase.GetComponent <gunMasterScript>().goGunOwner = NewCharacter; WeaponBase.transform.position = NewCharacter.transform.position; WeaponBase.transform.rotation = NewCharacter.transform.rotation; } else { WeaponBase = null; } // Creates script to control character, then edits its inputs char_Masterscript newCharScript = NewCharacter.AddComponent <char_Masterscript>(); newCharScript.SetInitValues(newUnit_ID, newUnit_Name, newUnit_Faction, newUnit_HP, newUnit_HasShields, newUnit_ShieldNum, newUnit_HasWeapon, WeaponBase); }
public void AddSquadMember(char_Masterscript newChara) { // Will be called by each generated character in the Squad squad_Members.Add(newChara); squad_Size = squad_Members.Count; }