// Use this for initialization void Start() { rg = this.GetComponent <Rigidbody>(); objToMove = this.transform; if (rg == null) { rg = this.GetComponentInParent <Rigidbody>(); objToMove = this.transform.parent.transform; } monStats = this.GetComponentInParent <MonsterStats>(); }
// Use this for initialization void Start() { animator = this.GetComponentInParent <Animator>(); parent = this.transform.parent.gameObject; if (parent.tag == "Enemy") { target = GameObject.FindWithTag("Player").transform; } monStats = this.GetComponentInParent <MonsterStats>(); rg = this.GetComponent <Rigidbody>(); if (rg == null) { rg = this.GetComponentInParent <Rigidbody>(); } }
public GameObject GenerateMonster(List<LimbStats> limbKeys) { GameObject monster = new GameObject("Monster"); monster.transform.position = new Vector3(0, 0, 0); monster.transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0)); Rigidbody mrg = monster.AddComponent<Rigidbody>(); //mrg.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY; monster.AddComponent<MeshCollider>(); monster.tag = "Monster"; //Make and add walk trigger with Roll script GameObject walkTrigger = Instantiate((GameObject)Resources.Load("GeneralWalkTrigger")); walkTrigger.transform.SetParent(monster.transform,false); //Add monster stats MonsterStats stats = monster.AddComponent<MonsterStats>(); //Add attack trigger GameObject attackTrigger = Instantiate((GameObject)Resources.Load("AttackTrigger")); attackTrigger.transform.SetParent(monster.transform, false); //For each limb key in inventory, add a limb to the monster and adjust its stats for (int i=0; i<limbKeys.Count; i++) { LimbStats key = limbKeys[i]; GameObject li = InstantiateLootLimb(key); li.transform.SetParent(monster.transform,false); li.transform.position = new Vector3(rand.Next(-25,25)*.01f, rand.Next(-25, 25) * .01f, rand.Next(-25, 25) * .01f); li.transform.rotation = Quaternion.Euler(new Vector3(rand.Next(0, 360), rand.Next(0, 360), rand.Next(0, 360))); Rigidbody r = li.transform.GetComponentInChildren<Rigidbody>(); MeshCollider mc = li.transform.GetComponentInChildren<MeshCollider>(); BoxCollider bc = li.transform.GetComponentInChildren<BoxCollider>(); Destroy(r); Destroy(mc); Destroy(bc); stats.accMod += key.accMod; stats.speedMod += key.speedMod; stats.healthMod += key.constMod; stats.damageMod += key.damageMod; } monster.transform.position = (GameObject.FindWithTag("Player").transform.position + new Vector3(3, 0, 3)); print("monster at " + monster.transform.position.x); return monster; }
// Use this for initialization void Start() { animator = this.GetComponentInParent<Animator>(); stats = this.GetComponentInParent<MonsterStats>(); parent = this.transform.parent.gameObject; }