// Instantiate particle effect on shot void FixedUpdate() { if (hasShots) { // Shoots a cannonball, tags the object, plays a particle, decreases the shot count, plays the cannonshot sound then updates the ui. if (Input.GetAxisRaw("FireLeft") != 0) { if (LT == false) { var cannon = Instantiate(cannonBallLeft) as GameObject; cannon.transform.position = new Vector3(cannonSpawnLeft.position.x, cannonSpawnLeft.position.y, cannonSpawnLeft.position.z); cannon.transform.rotation = playerShip.rotation; var cannonAnim = Instantiate(explosion) as GameObject; cannonAnim.transform.position = new Vector3(cannonSpawnLeft.position.x, cannonSpawnLeft.position.y, cannonSpawnLeft.position.z); cannonAnim.transform.rotation = cannonSpawnLeft.rotation; cannon.gameObject.tag = "PlayerCannonBall"; shotCount--; SoundsManager.PlayerSound(); ui.DisplayAmmo(shotCount); LT = true; } } if (Input.GetAxisRaw("FireLeft") == 0) { LT = false; } // Shoots a cannonball, tags the object, plays a particle, decreases the shot count, plays the cannonshot sound then updates the ui. if (Input.GetAxisRaw("FireRight") != 0) { if (RT == false) { var cannon = Instantiate(cannonBallRight) as GameObject; cannon.transform.position = new Vector3(cannonSpawnRight.position.x, cannonSpawnRight.position.y, cannonSpawnRight.position.z); cannon.transform.rotation = playerShip.rotation; cannon.gameObject.tag = "PlayerCannonBall"; var cannonAnim = Instantiate(explosion) as GameObject; cannonAnim.transform.position = new Vector3(cannonSpawnRight.position.x, cannonSpawnRight.position.y, cannonSpawnRight.position.z); cannonAnim.transform.rotation = cannonSpawnRight.rotation; shotCount--; SoundsManager.PlayerSound(); ui.DisplayAmmo(shotCount); RT = true; } } if (Input.GetAxisRaw("FireRight") == 0) { RT = false; } } if (shotCount == 0) { hasShots = false; Reload(); } }