public void ThrustBackward(float throttle) { if (fuel <= 0f) { return; } throttle = Mathf.Clamp(throttle, 0f, 1f); float speedRatio = Time.deltaTime * secondaryThrust * throttle; this.GetComponent <Rigidbody2D>().AddRelativeForce(new Vector2(0f, -speedRatio)); frontThruster1.EmitThrust(); frontThruster2.EmitThrust(); fuel -= speedRatio; this.GetComponent <Rigidbody2D>().mass -= (speedRatio / 100000); }
public void ThrustBackward(float throttle) { if (fuel <= 0f) { throttle = emptyThrottle; } throttle = Mathf.Clamp(throttle, 0f, 2f); float speedRatio = Time.deltaTime * secondaryThrust * throttle; this.GetComponent <Rigidbody2D>().AddRelativeForce(new Vector2(0f, -speedRatio)); if (throttle > thrusterThreshold) { frontThruster1.EmitThrust(throttle); frontThruster2.EmitThrust(throttle); } DeductFuel(speedRatio, throttle); this.GetComponent <Rigidbody2D>().mass -= (speedRatio / 100000); }
public void ThrustRight(float throttle) { if (fuel <= 0f) { return; } throttle = Mathf.Clamp(throttle, 0f, 1f); float speedRatio = Time.deltaTime * secondaryThrust * throttle; this.GetComponent <Rigidbody2D>().AddRelativeForce(new Vector2(speedRatio, 0f)); if (!leftThrustOn) { backLeftThruster.EmitThrust(); frontLeftThruster.EmitThrust(); } fuel -= speedRatio; this.GetComponent <Rigidbody2D>().mass -= (speedRatio / 100000); }
// Throttle should be 0 to 2, but get's clamped anyway! public void ThrustForward(float throttle) { if (fuel <= 0f) { throttle = emptyThrottle; } if (throttle > thrusterThreshold) { mainThruster.EmitThrust(throttle); } throttle = Mathf.Clamp(throttle, 0f, 2f); float speedRatio = Time.deltaTime * mainThrust * throttle; gameObject.GetComponent <Rigidbody2D>().AddRelativeForce(new Vector2(0f, speedRatio)); DeductFuel(speedRatio, throttle); gameObject.GetComponent <Rigidbody2D>().mass -= (speedRatio / 100000); }
// Throttle should be 0 to 1, but get's clamped anyway! public void ThrustForward(float throttle) { if (fuel <= 0f) { return; } if (!mainThrustOn) { mainThruster.EmitThrust(); mainThrustOn = true; } throttle = Mathf.Clamp(throttle, 0f, 1f); float speedRatio = Time.deltaTime * mainThrust * throttle; gameObject.GetComponent <Rigidbody2D>().AddRelativeForce(new Vector2(0f, speedRatio)); fuel -= speedRatio; gameObject.GetComponent <Rigidbody2D>().mass -= (speedRatio / 100000); }