void Update()
    {
        // If the player is in the cannon
        if (m_hasPlayer)
        {
            // Grab the input
            float v = Input.GetAxis("Vertical");
            // Rotate the camera
            m_cannonPivot.Rotate(Vector3.right, v * speed * Time.deltaTime);
            // Allow the target reticle to be controlled
            m_target.m_canControl = true;
            // Launch
            if (Input.GetButtonDown("Jump"))
            {
                ObjectLauncher launcher = m_player.GetComponent <ObjectLauncher>();

                // Set player time to target
                launcher.SetTime(m_timeToTarget);
                // Detach player
                m_player.transform.parent = null;
                // Set player target
                launcher.SetTarget(m_target.transform);
                // Disable kinematic on player
                m_player.GetComponent <Rigidbody>().isKinematic = false;
                // Launch the player
                launcher.LaunchProjectile();

                // Player no longer can control the cannon
                m_hasPlayer = false;
                // Stop the reticle control
                m_target.m_canControl = false;
            }
        }
    }
Ejemplo n.º 2
0
    public override void Launched(Vector3 direction, ObjectLauncher launcher)
    {
        //as they are pooled, they could have been already used and have previous velocity
        m_Rigidbody.velocity = Vector3.zero;

        m_Rigidbody.AddForce(direction * 200.0f);
        m_Launcher = launcher;

        m_Launched   = true;
        m_LaunchTime = 0.0f;
    }
Ejemplo n.º 3
0
 public abstract void Launched(Vector3 direction, ObjectLauncher launcher);