public void ThrustToVelocity(Vector3D velocity) { if (thrustPidController == null) { throw new Exception("wat de neuk thrustPid is null"); } if (thrustControl == null) { throw new Exception("wat de neuk thrustControl is null"); } if (ingameTime == null) { throw new Exception("wat de neuk ingameTime is null"); } Vector3D difference = velocity - ControlVelocity; double differenceMag = difference.Normalize(); double percent = thrustPidController.NextValue(differenceMag, (lastTime - ingameTime.Time).TotalSeconds); percent = MathHelperD.Clamp(percent, 0, 1); thrustControl.ApplyForce(difference, percent); lastTime = ingameTime.Time; }
public void ThrustToVelocity(Vector3D velocity) { Vector3D difference = velocity - ControlVelocity; double differenceMag = difference.Normalize(); double percent = thrustPidController.NextValue(differenceMag, (lastTime - ingameTime.Time).TotalSeconds); percent = MathHelperD.Clamp(percent, 0, 1); thrustControl.ApplyForce(difference, percent); lastTime = ingameTime.Time; }