protected RagdollControls targetRagdoll; //The target's Ragdoll Controls component public override void OnPickUp(GameObject target) { //Get Components targetWeaponAgent = target.GetComponent <WeaponAgent>(); targetRagdoll = target.GetComponent <RagdollControls>(); //If they can hold a weapon if (targetWeaponAgent != null) { //Unequip their last weapon targetWeaponAgent.Unequip(); //Equip the new weapon targetWeaponAgent.EquipWeapon(weapon); //Run the base pickup on pickup base.OnPickUp(target); //Reset their colliders to include the weapon if (targetRagdoll != null) { targetRagdoll.partColliders[targetRagdoll.partColliders.Count - 1] = targetWeaponAgent.equippedWeapon.GetComponent <Collider>(); } } }
// Use this for initialization void Start() { if (theType == WeaponType.HANDGUN) { ammo = 12; maxAmmo = 120; } if (theType == WeaponType.RIFLE) { ammo = 30; maxAmmo = 150; } // this is a messy way to do this, ask for the animator and get the gameobject, need another way if (gameObject.GetComponentInParent <Animator>().gameObject.CompareTag("AI")) { parentObj = GetComponentInParent <Animator> ().gameObject; theAgent = (WeaponAgent)parentObj.GetComponent <AIWeaponHandler> (); return; } if (gameObject.GetComponentInParent <Animator>().gameObject.CompareTag("Player")) { parentObj = GetComponentInParent <Animator> ().gameObject; theAgent = (WeaponAgent)parentObj.GetComponent <Player> (); return; } }
public bool died = false; //Weather the pawn is dead or not // Use this for initialization void Start() { //Get Components healthBar = gameObject.GetComponentInChildren <Slider>(); ragdoll = gameObject.GetComponent <RagdollControls>(); weaponAgent = gameObject.GetComponent <WeaponAgent>(); //Set health bar max healthBar.maxValue = maxHealth; //Set health to max health = maxHealth; }
void Start() { //Get Components weaponAgent = gameObject.transform.parent.parent.GetComponent <WeaponAgent>(); }
void Awake() { agent = GetComponent <WeaponAgent>(); }
protected override void OnTriggerEnter(Collider collider) { weaponAgent = collider.gameObject.GetComponent <WeaponAgent>(); base.OnTriggerEnter(collider); }