// Update is called once per frame void Update() { Vector3[] Points = new Vector3[10]; LineRend.SetPositions(Points); // If the max force has been exceeded and the shell hasn't yet been launched... if (CurrentLaunchForce >= MaxLaunchForce && !bFired) { // ... use the max force and launch the shell. CurrentLaunchForce = MaxLaunchForce; Fire(); } // Otherwise, if the fire button has just started being pressed... else if (Input.GetButtonDown("Fire" + PlayerNum)) { // ... reset the fired flag and reset the launch force. bFired = false; CurrentLaunchForce = MinLaunchForce; } // Otherwise, if the fire button is being held and the shell hasn't been launched yet... else if (Input.GetButton("Fire" + PlayerNum) && !bFired) { // Increment the launch force and update the slider. CurrentLaunchForce += ChargeSpeed * Time.deltaTime; Vector3 LanuchForce = CurrentLaunchForce * SpawnLocation.forward; Points = TrajectoryFunctions.GetTrajectoryPath(LanuchForce, SpawnLocation.position, 10, TrajectoryFunctions.TimeToReachTarget(LanuchForce, 15.0f, SpawnLocation.position.y, 0.0f)); LineRend.SetPositions(Points); } // Otherwise, if the fire button is released and the shell hasn't been launched yet... else if (Input.GetButtonUp("Fire" + PlayerNum) && !bFired) { // ... launch the shell. Fire(); } }