private void FixedUpdate() { if (_MainPropeller != null) { _MainPropeller.SetThrust(0.75f); } }
private void FixedUpdate() { #region PropellerInput //Forward and Back if (Input.GetAxis("Vertical") != 0) { Main_Screw.SetThrust(Input.GetAxis("Vertical")); } //Left if (Input.GetAxis("Horizontal") < 0) { L_Screw.SetThrust(Mathf.Abs(Input.GetAxis("Horizontal"))); } //Right if (Input.GetAxis("Horizontal") > 0) { R_Screw.SetThrust(Input.GetAxis("Horizontal")); } #endregion PropellerInput #region Buoyancy if (_Neutral) //F=G { float F = _Rb.velocity.y; _CurrentForce = F; if (MainBallast != null) { MainBallast.ApplyBuoyancy(-F); } } if (!_Neutral) { if (transform.position.y < 0)//Natural buoyancy { float F = SubClass.DiveSpeed; _CurrentForce = 1; if (MainBallast != null) { MainBallast.ApplyBuoyancy(F); } } if (transform.position.y > 0)//Surface tension when leaving water { float w = _Rb.velocity.y * WaterTension.Evaluate(Time.deltaTime * 0.01f); _Rb.velocity = new Vector3(_Rb.velocity.x, w, _Rb.velocity.z); } } if (_Diving)//Positve Buoyancy { float F = -SubClass.DiveSpeed; _CurrentForce = -1; if (MainBallast != null) { MainBallast.ApplyBuoyancy(F); } } #endregion Buoyancy }
private IEnumerator Fire() { while (_Active) { SetBallast(); _Propeller.SetThrust(0.75f); yield return(new WaitForFixedUpdate()); yield return(null); } }