Beispiel #1
0
        private void Update()
        {
            // If the max force has been exceeded and the shell hasn't yet been launched...
            if (m_Held)
            {
                if (Input.GetButtonDown(m_ActiveButton))
                {
                    ActivatableObject activation = m_HeldObject.gameObject.GetComponent <ActivatableObject>();
                    if (activation != null)
                    {
                        activation.Activate(this.gameObject);
                    }
                }

                if (Input.GetButtonUp(m_FireButton))
                {
                    //drop object
                    Drop();
                }

                // Error checking and object movement
                if (m_HeldObject != null)
                {
                    m_HeldObject.transform.SetPositionAndRotation(m_FireTransform.position, m_FireTransform.rotation);
                }
                else
                {
                    m_Held = false;
                }
            }
            // Otherwise, if the fire button has just started being pressed...

            /*
             * else if (Input.GetButton (m_FireButton) && !m_Fired)
             * {
             *
             * }
             * // Otherwise, if the fire button is released and the shell hasn't been launched yet...
             * else if (Input.GetButtonUp (m_FireButton) && !m_Fired)
             * {
             *  // ... launch the shell.
             *  Fire ();
             * }*/
        }
Beispiel #2
0
        private void OnTriggerStay(Collider other)
        {
            if (other.gameObject.tag == "Pickup" || (other.gameObject.tag == "Button"))
            {
                if (Input.GetButtonDown(m_FireButton) && other.gameObject.tag == "Pickup")
                {
                    Pickup(other.gameObject);
                    Debug.Log("Player " + m_PlayerNumber + " picked up an object.");
                }

                if (Input.GetButtonDown(m_ActiveButton))
                {
                    ActivatableObject activation = other.gameObject.GetComponent <ActivatableObject>();
                    if (activation != null)
                    {
                        activation.Activate(this.gameObject);
                    }
                }
            }
        }