ProjectileCannon.Shoot C# (CSharp) Method

Shoot() public method

public Shoot ( ) : void
return void
    public override void Shoot()
    {
        isActive    = true;
        isExpired   = false;
        hasCollided = false;
        hasExploded = false;

        timeShoot = Time.time;

        initialPosition = shooter.transform.position;
        initialOrientation = shooter.transform.rotation;

        transform.position = initialPosition;
        transform.rotation = initialOrientation;
    }

Usage Example

Example #1
0
// fonction appelée lorsque l'arme de la tour est activée
public override void Shoot()
{
    if (Time.time - timeLastShoot > frequency)
    {
        isShooting = true;

        timeLastShoot = Time.time;

        if (projectilePoolReady.Count > 0)
        {
            go = (GameObject)projectilePoolReady[0];
            go.SetActive(true);

            goRigidBody             = go.GetComponent(typeof(Rigidbody)) as Rigidbody;
            goRigidBody.isKinematic = false;
            goRigidBody.AddForce(shootFromTransform.transform.forward * force, ForceMode.Impulse);

            bullet = go.GetComponent(typeof(ProjectileCannon)) as ProjectileCannon;

            bullet.shooter = shootFromTransform;
            bullet.target  = null;

            bullet.Shoot();

            projectilePoolReady.RemoveAt(0);
            projectilePoolActive.Add(go);
        }
    }
    else
    {
        isShooting = false;
    }
}
All Usage Examples Of ProjectileCannon::Shoot