void OnTriggerEnter2D(Collider2D collider) { PlayerWeaponScript projectile = collider.gameObject.GetComponent <PlayerWeaponScript>(); PlayerController player = collider.gameObject.GetComponent <PlayerController>(); WallScript wall = collider.gameObject.GetComponent <WallScript>(); try { if (!(projectile == null)) { if (!projectile.shotType.Equals("plasma") && !projectile.shotType.Equals("rock")) { Destroy(collider.gameObject); } } if (player != null && (caster != null && !caster.Equals(player))) { player.health.ManualDamage(1, "rock"); } } catch (System.NullReferenceException e) { if (!(wall == null)) { gameObject.GetComponent <Rigidbody2D>().isKinematic = false; } } }
public void CreateShot(PlayerController player) { if (cooldown <= 0) { cooldown = cooldownRate; if (fountainType.Equals("plasma")) { var shot = Instantiate(shotPrefab) as Transform; shot.position = transform.position; PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>(); player.weapon = shotScript; shotScript.caster = player; shotScript.MoveToCaster(); } if (fountainType.Equals("fire")) { var shot1 = Instantiate(shotPrefab) as Transform; var shot2 = Instantiate(shotPrefab) as Transform; var shot3 = Instantiate(shotPrefab) as Transform; shot1.position = shot2.position = shot3.position = transform.position; PlayerWeaponScript shotScript1 = shot1.gameObject.GetComponent <PlayerWeaponScript>(); PlayerWeaponScript shotScript2 = shot2.gameObject.GetComponent <PlayerWeaponScript>(); PlayerWeaponScript shotScript3 = shot3.gameObject.GetComponent <PlayerWeaponScript>(); player.weapon = shotScript1; player.weapons.Push(shotScript2); player.weapons.Push(shotScript3); shotScript1.caster = shotScript2.caster = shotScript3.caster = player; //shotScript1.caster = player; //shotScript2.caster = player; //shotScript3.caster = player; shotScript1.MoveToCaster(); shotScript2.MoveToCaster(); shotScript3.MoveToCaster(); } else if (fountainType.Equals("water")) { var shot = Instantiate(shotPrefab) as Transform; shot.position = transform.position; PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>(); player.weapon = shotScript; shotScript.caster = player; shotScript.MoveToCaster(); if (player.burning) { player.burning = false; Transform burnParticles = player.transform.GetChild(0); ParticleSystem nbaJamOnFireEdition = burnParticles.GetComponent <ParticleSystem>(); nbaJamOnFireEdition.Stop(); Destroy(shotScript.gameObject); } } Transform particles = transform.GetChild(0); ParticleSystem p = particles.GetComponent <ParticleSystem>(); p.Stop(); AnimationController2D anim = GetComponent <AnimationController2D>(); anim.setAnimation(fountainType + "Despawn"); } }
void OnTriggerExit2D(Collider2D collider) { PlayerWeaponScript shot = collider.gameObject.GetComponent <PlayerWeaponScript>(); if (shot != null && shot.fire && !shot.rock) { shot.connected = true; } }
void Awake() { var shot = Instantiate(defaultShot) as Transform; shot.position = transform.position; PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>(); weapon = shotScript; shotScript.caster = this; shotScript.MoveToCaster(); frozen = false; }
private void Awake() { if (instance == null) { instance = this; } else { return; } gunSpriteRen = GetComponent <SpriteRenderer>(); ammoTypeCount = ammoTypes.Length; }
void OnTriggerEnter2D(Collider2D collider) { PlayerWeaponScript shot = collider.gameObject.GetComponent <PlayerWeaponScript>(); if (shot != null && shot.fire && !shot.rock) { //shot.fire = true; shot.connected = true; if (shot.shotType.Equals("plasma")) { shot.caster = null; } } }
void OnTriggerEnter2D(Collider2D collider) { PlayerWeaponScript projectile = collider.gameObject.GetComponent <PlayerWeaponScript>(); if (player == null) { player = collider.gameObject.GetComponent <PlayerController>(); if (player != null) { player.nearRock = true; player.rock = this; } } }
public IEnumerator DropBomb() { canDropBomb = false; // Pooling Method : grab a bullet from "ObjectPooler"'s gameObjects list bombClone = weaponPool.Spawn(); bombClone.transform.position = new Vector3(myTr.position.x, myTr.position.y, myTr.position.z); playerWeaponScript = bombClone.GetComponent <PlayerWeaponScript>() as PlayerWeaponScript; playerWeaponScript.type = 5; // bomb playerWeaponScript.direction = new Vector2(0.55f, -1.0f); yield return(new WaitForSeconds(bombDelay)); canDropBomb = true; }
void OnTriggerEnter2D(Collider2D collider) { //player = gameObject.GetComponent<PlayerScript>(); PlayerWeaponScript shot = collider.gameObject.GetComponent <PlayerWeaponScript> (); GameObject killz = collider.gameObject; if (shot != null && !player.dead) { PlayerController target = shot.caster; if (target == null || !target.Equals(player)) { hp -= shot.damage; if (hp <= 0) { manager.KillPlayer(player.name); if (player.weapon != null) { Destroy(player.weapon); } player.dead = true; player.DeathAnim(shot.shotType); } } } else if ((killz.gameObject.tag.Equals("KillZ") || killz.gameObject.tag.Equals("Spikes")) && !player.dead) { if (killz.gameObject.tag.Equals("Spikes")) { Transform blood = transform.GetChild(3); ParticleSystem bloody = blood.GetComponent <ParticleSystem>(); bloody.Play(); } hp = 0; manager.KillPlayer(player.name); if (player.weapon != null) { Destroy(player.weapon); } player.dead = true; player.DeathAnim(killz.gameObject.tag); } }
// Update is called once per frame void Update() { // 3 - Retrieve axis information float inputX = Input.GetAxis("Horizontal"); float inputY = Input.GetAxis("Vertical"); // 4 - Movement per direction movement = new Vector2( speed.x * inputX, speed.y * inputY); // Update flame trail when moving downward or not. Transform PlayerFlame = transform.Find("PlayerFlame"); anim = PlayerFlame.GetComponent <Animator>(); if (PlayerFlame != null & inputY < 0) { anim.SetTrigger("flame_shrink"); } else { anim.SetTrigger("flame_grow"); } // 5 - Shooting bool shoot = Input.GetButton("Fire1"); shoot |= Input.GetButton("Fire2"); // Careful: For Mac users, ctrl + arrow is a bad idea if (shoot) { PlayerWeaponScript weapon = GetComponentInChildren <PlayerWeaponScript>(); if (weapon != null) { // false because the player is not an enemy weapon.Attack(false); } } // 6 - Make sure we are not outside the camera bounds var dist = (transform.position - Camera.main.transform.position).z; var leftBorder = Camera.main.ViewportToWorldPoint( new Vector3(0, 0, dist) ).x; var rightBorder = Camera.main.ViewportToWorldPoint( new Vector3(1, 0, dist) ).x; var topBorder = Camera.main.ViewportToWorldPoint( new Vector3(0, 0, dist) ).y; var bottomBorder = Camera.main.ViewportToWorldPoint( new Vector3(0, 1, dist) ).y; transform.position = new Vector3( Mathf.Clamp(transform.position.x, leftBorder, rightBorder), Mathf.Clamp(transform.position.y, topBorder, bottomBorder), transform.position.z ); }
// Update is called once per frame void Update() { float x = GetComponent <Transform>().position.x; float y = GetComponent <Transform>().position.y; if (player == 1) { if (Input.GetKey(KeyCode.W)) { //print("UP"); transform.position += new Vector3(0.0f, 0.1f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 180); } else if (Input.GetKey(KeyCode.S)) { transform.position -= new Vector3(0.0f, 0.1f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 0); } else if (Input.GetKey(KeyCode.A)) { transform.position -= new Vector3(0.1f, 0.0f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 270); } else if (Input.GetKey(KeyCode.D)) { transform.position += new Vector3(0.1f, 0.0f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 90); } shoot = Input.GetKeyDown(KeyCode.F); shoot |= Input.GetKeyDown(KeyCode.F); } else if (player == 2) { if (Input.GetKey(KeyCode.UpArrow)) { transform.position += new Vector3(0.0f, 0.1f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 180); } else if (Input.GetKey(KeyCode.DownArrow)) { transform.position -= new Vector3(0.0f, 0.1f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 0); } else if (Input.GetKey(KeyCode.LeftArrow)) { transform.position -= new Vector3(0.1f, 0.0f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 270); } else if (Input.GetKey(KeyCode.RightArrow)) { transform.position += new Vector3(0.1f, 0.0f, 0.0f); transform.eulerAngles = new Vector3(0, 0, 90); } shoot = Input.GetKeyDown(KeyCode.RightControl); shoot |= Input.GetKeyDown(KeyCode.RightControl); } if (shoot) { PlayerWeaponScript weapon = GetComponentInChildren <PlayerWeaponScript>(); if (weapon != null) { weapon.Attack(false); SoundEffectsHelper.Instance.MakePlayerShotSound(); } } }
void OnTriggerEnter2D(Collider2D collider) { PlayerWeaponScript projectile = collider.gameObject.GetComponent <PlayerWeaponScript>(); PlayerController player = collider.gameObject.GetComponent <PlayerController>(); WallScript wall = collider.gameObject.GetComponent <WallScript>(); // Collided with another projectile if (!(projectile == null) && !(caster == null) && !projectile.caster.Equals(this.caster)) { if (shotType.Equals("air")) { if (fire) { if (projectile.shotType.Equals("fire") || projectile.shotType.Equals("water")) { projectile.direction.x *= -1; projectile.direction.y *= -1; } Destroy(gameObject); } } if (shotType.Equals("fire")) { if (projectile.shotType.Equals("water")) { Destroy(projectile.gameObject); Destroy(gameObject); } } if (shotType.Equals("water")) { } } // Collided with a player else if (player != null && fire) { if (shotType.Equals("rock") && speed.x > 1 && (caster == null || !caster.Equals(player))) { Debug.Log("rock collision"); float mag = speed.magnitude; HealthScript h = player.GetComponent <HealthScript>(); //player.GetComponent<SpriteRenderer> ().color = new Color(150, 0, 0); //h.ManualDamage(1,"rock"); } if (caster == null || !caster.Equals(player)) { if (shotType.Equals("air")) { float apv = speed.magnitude; player.AirPushVelocity = (5 / airTime) * direction.x; player.pushed = true; connected = true; } if (shotType.Equals("water")) { animator.setAnimation("waterFreeze"); player._animator.setAnimation(player.character + " Frozen"); player.jumpHeight = 0.25f; player.frozen = true; player.freezeWarmup = player.freezeTime; connected = true; speed = new Vector2(2, 2); } if (shotType.Equals("fire")) { if (!player.burning) { player.burning = true; player.burnDown = player.burnTime; Transform burnParticles = player.transform.GetChild(0); ParticleSystem nbaJamOnFireEdition = burnParticles.GetComponent <ParticleSystem>(); nbaJamOnFireEdition.Play(); connected = true; } } if (shotType.Equals("plasma")) { connected = true; if (shotType.Equals("plasma")) { caster = null; } //player.GetComponent<SpriteRenderer> ().color = new Color(150, 0, 0); } } } }
// Update is called once per frame void Update() { if (!dead) { if (hitAnim > 0) { colorChange.color = new Color(150, 0, 0); hitAnim -= Time.deltaTime; } else { colorChange.color = baseColor; } Debug.Log("AirPushVelocity = " + AirPushVelocity); if (airCooldown > 0 && weapon == null) { airCooldown -= Time.deltaTime; } if (airCooldown <= 0 && weapon == null && !(weapons.Count > 0)) { var shot = Instantiate(defaultShot) as Transform; shot.position = transform.position; PlayerWeaponScript shotScript = shot.gameObject.GetComponent <PlayerWeaponScript>(); weapon = shotScript; shotScript.caster = this; shotScript.MoveToCaster(); } if (fireCooldown > 0) { fireCooldown -= Time.deltaTime; } if (burning) { burnDown -= Time.deltaTime; if (burnDown <= 0f) { health.ManualDamage(health.hp, "fire"); } } Vector3 velocity = _controller.velocity; if (_controller.isGrounded && _controller.ground != null && _controller.ground.tag == "MovingPlatform") { this.transform.parent = _controller.ground.transform; } else { if (this.transform.parent != null) { this.transform.parent = null; } } // Gravity: pull player down if (!Bounce) { velocity.y += gravity * Time.deltaTime; } // Player is bouncing else if (Bounce) { if (velocity.y > 0) { velocity.y *= 2.25f; } else if (velocity.y < 9 && velocity.y > -9) { velocity.y = 20; } else { velocity.y += -velocity.y * 2.25f; } if (velocity.y > maxHeight) { velocity.y = maxHeight; } Bounce = false; } if (!frozen) { // Player is moving horizontally //if (MultiInput.GetAxis("Horizontal", "", name) < 0 || MultiInput.GetAxis("LeftJoystickX", "", name) < 0) if (MultiInput.GetAxis("LeftJoystickX", "", name) < 0) { if (slide) { if (velocity.x > 0) { velocity.x += -walkSpeed * 0.002f; } else { velocity.x += -walkSpeed * 0.11f; } } else if (RunLeft | RunRight) { RunArrows = true; } else if (!_controller.isGrounded) { velocity.x = -airSpeed; } else { velocity.x = -walkSpeed; } if (!_controller.isGrounded) { _animator.setAnimation(character + " Jump"); } else { _animator.setAnimation(character + " Walk"); } _animator.setFacing("Left"); faceRight = false; } //else if (MultiInput.GetAxis("Horizontal", "", name) > 0 || MultiInput.GetAxis("LeftJoystickX", "", name) > 0) else if (MultiInput.GetAxis("LeftJoystickX", "", name) > 0) { if (slide) { if (velocity.x < 0) { velocity.x += walkSpeed * 0.002f; } else { velocity.x += walkSpeed * 0.11f; } } else if (RunLeft | RunRight) { RunArrows = true; } else if (!_controller.isGrounded) { velocity.x = airSpeed; } else { velocity.x = walkSpeed; } if (!_controller.isGrounded) { _animator.setAnimation(character + " Jump"); } else { _animator.setAnimation(character + " Walk"); } _animator.setFacing("Right"); faceRight = true; } else if (!_controller.isGrounded) { _animator.setAnimation(character + " Jump"); } else { _animator.setAnimation(character + " Idle"); if (slide) { velocity.x += velocity.x * 0.05f; } else if (RunArrows) { velocity.x += velocity.x * 3; } else if (pushed) { velocity.x += velocity.x * 1.2f; } else if (_controller.isGrounded) { velocity.x = 0; } } } else if (frozen) { freezeWarmup -= Time.deltaTime; if (freezeWarmup <= 0) { frozen = false; jumpHeight = 2; } } if (RunLeft || RunRight) { RunArrows = true; } if (RunArrows) { if (RunRight) { velocity.x += RunArrowStrength; velocity.y += 10; } else if (RunLeft) { velocity.x -= RunArrowStrength; velocity.y += 10; } AirControl = false; } if (pushed) { if (!faceRight) { Debug.Log("AirPushVelocity = " + AirPushVelocity); velocity.x += AirPushVelocity; velocity.y += 3; } else if (faceRight) { Debug.Log("AirPushVelocity = " + AirPushVelocity); velocity.x -= AirPushVelocity; velocity.y += 3; } pushed = false; hitAnim = hitAnimTime; } //if ((MultiInput.GetAxis("Vertical", "", name) < 0 || MultiInput.GetAxis("LeftJoystickY", "", name) > 0) && !_controller.isGrounded) if (MultiInput.GetButton("LeftBumper", "", name) && !_controller.isGrounded) { velocity.y += gravity * Time.deltaTime * 3; } velocity.x *= 0.85f; if (!_controller.isGrounded && !doubleJumped) { doubleJump = true; } if (_controller.isGrounded) { doubleJumped = false; doubleJump = false; } // Double jump //if (!doubleJumped && doubleJump && (MultiInput.GetButtonDown("Jump", "", name) || MultiInput.GetButtonDown("A", "", name) // || MultiInput.GetButtonDown("LeftBumper", "", name))) if (!doubleJumped && doubleJump && (MultiInput.GetButtonDown("A", "", name) || MultiInput.GetButtonDown("LeftBumper", "", name))) { velocity.y = 0; velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity); doubleJump = false; doubleJumped = true; Transform djParticle = transform.GetChild(1); ParticleSystem dj = djParticle.GetComponent <ParticleSystem>(); dj.Play(); } // First jump //else if ((MultiInput.GetButtonDown("Jump", "", name) || MultiInput.GetButtonDown("A", "", name) // || MultiInput.GetButtonDown("LeftBumper", "", name)) && _controller.isGrounded) else if ((MultiInput.GetButtonDown("A", "", name) || MultiInput.GetButtonDown("LeftBumper", "", name)) && _controller.isGrounded) { audioPlayer.PlayOneShot(sounds.Jump); velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity); doubleJump = true; doubleJumped = false; } pushed = false; colorTimer = true; _controller.move(velocity * Time.deltaTime); RunArrows = false; if (_controller.isGrounded) { AirControl = true; } //float inputX = MultiInput.GetAxis("Horizontal", "", name); float inputX = MultiInput.GetAxis("LeftJoystickX", "", name); //float inputY = MultiInput.GetAxis("Vertical", "", name); float inputY = MultiInput.GetAxis("LeftJoystickY", "", name); float aimX = MultiInput.GetAxis("RightJoystickX", "", name); float aimY = MultiInput.GetAxis("RightJoystickY", "", name); //bool shoot = Input.GetButtonDown("Shoot_P1"); //bool shoot = MultiInput.GetButtonDown("Shoot", "", name); bool shoot = MultiInput.GetButton("RightBumper", "", name); //bool grab = MultiInput.GetButtonDown("Grab","",name); float grab = MultiInput.GetAxis("X", "", name); if (shoot && fireCooldown <= 0) { fireCooldown = fireRate; if (weapon != null && weapon.hasShot) { if (weapon.rock) { weapon.gameObject.GetComponent <Rigidbody2D>().gravityScale = 6; } if (weapon.shotType.Equals("air") && airCooldown <= 0) { airCooldown = airFireRate; if (aimX != 0 || aimY != 0) { float x = aimX * 10; float y = aimY * 10; float z = -(Mathf.Atan2(y, x) * 57.2958f); if (aimX < 0) { weapon.gameObject.transform.Rotate(180, 0, -z, Space.Self); } else { weapon.gameObject.transform.Rotate(0, 0, z, Space.Self); } weapon.Attack(aimX, aimY); } else { if (faceRight) { weapon.Attack(1, 0); } else { weapon.gameObject.transform.Rotate(180, 0, 180, Space.Self); weapon.Attack(-1, 0); } } weapon = null; } else { if (aimX != 0 || aimY != 0) { float x = aimX * 10; float y = aimY * 10; float z = -(Mathf.Atan2(y, x) * 57.2958f); weapon.Attack(aimX, aimY); Debug.Log("this is happening"); } else { if (faceRight) { weapon.Attack(1, 0); } else { weapon.Attack(-1, 0); } } // Post weapon firing if (weapons.Count > 0) { weapon = (PlayerWeaponScript)weapons.Pop(); } else { weapon = null; } } } airCooldown += 0.75f; } if (grab > 0) { if (nearRock) { if (weapon != null && weapon.shotType.Equals("air")) { Destroy(weapon.gameObject); } while (weapons.Count > 0) { weapon = (PlayerWeaponScript)weapons.Pop(); Destroy(weapon.gameObject); } weapon = rock.gameObject.GetComponentInParent <PlayerWeaponScript>(); //weapon.rockScript.player = this; weapon.caster = this; weapon.gameObject.GetComponent <Rigidbody2D>().gravityScale = 0; } else if (inFountain) { if (weapon != null && weapon.shotType.Equals("air") && weapons.Count == 0) { Destroy(weapon.gameObject); fountain.CreateShot(this); } else if (weapon == null) { fountain.CreateShot(this); if (weapon.shotType.Equals("water")) { burning = false; Transform burnParticles = transform.GetChild(0); ParticleSystem nbaJamOnFireEdition = burnParticles.GetComponent <ParticleSystem>(); nbaJamOnFireEdition.Stop(); } } } } } else { if (plasmaDeath) { transform.Rotate(new Vector3(0, 0, 10)); transform.localScale = new Vector3(transform.localScale.x * 0.95f, transform.localScale.y * 0.95f, 0f); } } }
void Start() { ChildGameObject1 = transform.parent.transform.GetChild(0).GetComponent <PlayerWeaponScript>(); ChildGameObject2 = transform.parent.transform.GetChild(1).GetComponent <PlayerWeaponScript>(); ChildGameObject3 = transform.parent.transform.GetChild(2).GetComponent <PlayerWeaponScript>(); }
public IEnumerator LaunchProjectile(bool buttonKeptDown) { // If canShoot is already false, then abort the function if (canShoot == false || upgrading == true || renderer.isVisible == false) { yield break; //return null; // FIX CS 13 01 2015 VERIFIER !! } // Set canShoot to false until we process the function and the 'shootDelay' canShoot = false; // If player has bomb call "DropBomb()" function if (hasBomb == true && canDropBomb == true) { StartCoroutine(DropBomb()); } // If we don't use auto-fire ("Fire2") button and simple fire button ("space" or "Fire1") is kept pressed, // then slow down the fire rate by adding an additional delay ! // This is meant to encourage intensive button press. if (buttonKeptDown == true && (Input.GetKey("space") || Input.GetButton("Fire1"))) { yield return(new WaitForSeconds(shootDelay)); } if (bulletCount < bulletCountLimiter) { //REGULAR METHOD : INSTANTIATE bullet (unoptimised) //bulletClone = Instantiate(bullet, Vector3 (myTr.position.x+0.2, myTr.position.y-0.005, myTr.position.z), Quaternion.identity); // SMARTPOOL SYSTEM if (weaponLevel == 1) { // Pooling Method : grab a bullet from "ObjectPooler"'s gameObjects list bulletClone = weaponPool.Spawn(); bulletClone.transform.position = new Vector3(myTr.position.x + 0.2f, myTr.position.y - 0.005f, myTr.position.z); playerWeaponScript = bulletClone.GetComponent <PlayerWeaponScript>() as PlayerWeaponScript; playerWeaponScript.type = 1; // horizontal bullet playerWeaponScript.direction = new Vector2(1.0f, 0.0f); // Set the direction of the bullet bulletCount = bulletCount + 1; } else if (weaponLevel == 2) { // Pooling Method : grab a bullet from "ObjectPooler"'s gameObjects list bulletClone = weaponPool.Spawn(); bulletClone.transform.position = new Vector3(myTr.position.x + 0.2f, myTr.position.y - 0.005f, myTr.position.z); playerWeaponScript = bulletClone.GetComponent <PlayerWeaponScript>() as PlayerWeaponScript; playerWeaponScript.type = 1; // horizontal bullet playerWeaponScript.direction = new Vector2(1.0f, 0.0f); bulletClone = weaponPool.Spawn(); bulletClone.transform.position = new Vector3(myTr.position.x + 0.2f, myTr.position.y - 0.005f, myTr.position.z); playerWeaponScript = bulletClone.GetComponent <PlayerWeaponScript>() as PlayerWeaponScript; playerWeaponScript.type = 2; // diagonal bullet playerWeaponScript.direction = new Vector2(1.0f, 0.5f); bulletCount = bulletCount + 2; } else if (weaponLevel == 3) { // Pooling Method : grab a bullet from "ObjectPooler"'s gameObjects list bulletClone = weaponPool.Spawn(); bulletClone.transform.position = new Vector3(myTr.position.x + 0.2f, myTr.position.y - 0.005f, myTr.position.z); playerWeaponScript = bulletClone.GetComponent <PlayerWeaponScript>() as PlayerWeaponScript; playerWeaponScript.type = 4; // horizontal bullet playerWeaponScript.direction = new Vector2(1.0f, 0.0f); bulletCount = bulletCount + 1; } // Play bullet sound audio.clip = bulletSound; audio.Play(); } // Wait for weapon shoot delay yield return(new WaitForSeconds(shootDelay)); // shoot delay is now finished, set back "canShoot" to true, so we can fire again canShoot = true; }