private void Start() { gun = GameObject.Find("SciFiRifleRight"); gunLogic = gun.GetComponent <GunLogic>(); gameManager = FindObjectOfType <GameManager>(); UIcomponent = gameManager.GetComponent <UIManager>(); }
void Update() { horizontal = Input.GetAxis("Horizontal"); vertical = Input.GetAxis("Vertical"); if (interactiveObject && Input.GetButtonDown("Fire2")) { if (equippedObject == null) { GunLogic gun = interactiveObject.GetComponent <GunLogic>(); if (gun) { interactiveObject.transform.position = equipPos.position; interactiveObject.transform.parent = this.gameObject.transform; interactiveObject.transform.rotation = equipPos.rotation; gun.EquipGun(); equippedObject = interactiveObject; } } else if (equippedObject) { GunLogic gun = equippedObject.GetComponent <GunLogic>(); if (gun) { equippedObject.transform.parent = null; gun.UnequipGun(); equippedObject = null; } } } }
void OnTriggerEnter(Collider other) { GunLogic gunLogic = other.GetComponentInChildren <GunLogic>(); if (gunLogic) { gunLogic.AddAmmo(m_BulletAmmo, m_GrenadeAmmo); Destroy(gameObject); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { GunLogic gunLogic = other.GetComponentInChildren <GunLogic>(); if (gunLogic) { gunLogic.RefillAmmo(); Destroy(gameObject); } } }
// Start is called before the first frame update private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { print("Player"); GunLogic gunlogic = other.GetComponentInChildren <GunLogic>(); if (gunlogic) { gunlogic.reload(); Destroy(gameObject); } } }
// -------------------------------------------------------------- void Start() { // Hide the menu m_Menu.SetActive(false); m_Cats = GameObject.FindGameObjectsWithTag("Cat"); if (m_Player) { m_PlayerScript = m_Player.GetComponent <PlayerController>(); } if (m_Gun) { m_GunScript = m_Gun.GetComponent <GunLogic>(); } }
// Update is called once per frame void Update() { m_horizontalInput = Input.GetAxis("Horizontal"); m_verticalInput = Input.GetAxis("Vertical"); m_movementInput = new Vector3(m_horizontalInput, 0, m_verticalInput); if (!m_jump && Input.GetButtonDown("Jump")) { m_jump = true; } if (m_interactiveObject && Input.GetButtonDown("Fire2")) { if (!m_equippedObject) { GunLogic gunLogic = m_interactiveObject.GetComponent <GunLogic>(); if (gunLogic) { // Sets the position of the gun m_interactiveObject.transform.position = m_weaponEquipmentPosition.position; m_interactiveObject.transform.rotation = m_weaponEquipmentPosition.rotation; m_interactiveObject.transform.parent = gameObject.transform; // Deactivates gravity, deactivates collider gunLogic.EquipGun(); m_equippedObject = m_interactiveObject; } } else if (m_equippedObject) { GunLogic gunLogic = m_equippedObject.GetComponent <GunLogic>(); if (gunLogic) { // Sets the position of the gun m_equippedObject.transform.parent = null; // Activates gravity, activates collider gunLogic.UnequipGun(); m_equippedObject = null; } } } }