void ThrowFireball() { GameObject fireball = Instantiate(fireballPrefab, rigidbody2d.position + Vector2.up * 0.5f, Quaternion.identity); Fireball projectile = fireball.GetComponent <Fireball>(); projectile.Launch(lookDirection, 600); animator.SetTrigger("Launch"); }
private void FireBallAttack() { Vector2 spawnposition = new Vector2(1.5f, 1.0f); Vector2 initialposition = rigidbody2d.position; // flip the spawn position. if (lookDirection.x < 0f) { spawnposition.x = -spawnposition.x; } GameObject fireballspawn = Instantiate(fireball, initialposition + spawnposition, Quaternion.identity); Fireball fireballattack = fireballspawn.GetComponent <Fireball>(); fireballattack.Launch(lookDirection, 300, initialposition, this.gameObject); }
private void Shoot() { if (canShoot) { Vector2 direction = GetGlobalMousePosition() - GlobalPosition; direction = direction.Normalized(); Fireball spawnedFireBall = (Fireball)fireBallScene.Instance(); GetTree().Root.AddChild(spawnedFireBall); spawnedFireBall.GlobalPosition = GlobalPosition; spawnedFireBall.Launch(direction); canShoot = false; attackSpeedTimer.Start(attackSpeed); } }
private void OnTriggerEnter(Collider other) { if (ProjectileMask == (ProjectileMask | (1 << other.gameObject.layer))) { if (Hand.Velocity.magnitude > _minimumVelocity) { Fireball fireBall = other.gameObject.GetComponent <Fireball>(); if (fireBall.Active) { Vector3 force = Hand.Velocity * ForcePercentageCharged * _forcePower; if (fireBall.Armed) { fireBall.ApplyForce(force); } else { fireBall.Launch(force); } } } } }