public void FollowNew(Transform target)
    {
        targetFollow = target;
        CannonBall ball = target.GetComponent <CannonBall>();

        if (ball != null)
        {
            StartCoroutine("CheckForSleep", ball.GetComponent <Rigidbody2D>());
        }
    }
    public void FireCannon()
    {
        CannonBall newBall = Instantiate(cannonBallPrefab, transform.position, transform.rotation);

        newBall.setTimeToArm(30f);
        newBall.setTimeToDetonate(cannonsController.CannonBallDistance);
        Rigidbody rigidbody;

        rigidbody = newBall.GetComponent <Rigidbody>();
        rigidbody.AddForce(transform.up * cannonsController.CannonThrustForce * cannonsController.CannonsThrustMaxForce);
    }
Beispiel #3
0
    private void Shoot()
    {
        if (!runOnce)
        {
            return;
        }

        runOnce    = false;
        isCharging = false;

        cannonBall.transform.parent = null;
        Rigidbody rb = cannonBall.GetComponent <Rigidbody>();

        rb.isKinematic = false;
        rb.AddForce(transform.forward * chargePower * GameDefine.CANNON_POWER_PER_CHARGE);

        Instantiate(vfxShoot, cannonBall.transform.position, Quaternion.identity);
    }