protected override void OnStep() { var p = TestSettings.Camera.transform.position; p.x = _car.GetPosition().X; TestSettings.Camera.transform.position = p; if (Input.GetKeyDown(KeyCode.A)) { _spring1.SetMotorSpeed(_speed); } if (Input.GetKeyDown(KeyCode.S)) { _spring1.SetMotorSpeed(0.0f); } if (Input.GetKeyDown(KeyCode.D)) { _spring1.SetMotorSpeed(-_speed); } if (Input.GetKeyDown(KeyCode.Q)) { _hz = Math.Max(0.0f, _hz - 1.0f); _spring1.SetSpringFrequencyHz(_hz); _spring2.SetSpringFrequencyHz(_hz); } if (Input.GetKeyDown(KeyCode.E)) { _hz += 1.0f; _spring1.SetSpringFrequencyHz(_hz); _spring2.SetSpringFrequencyHz(_hz); } }
/// <inheritdoc /> protected override void OnRender() { var torque = _joint.GetMotorTorque(TestSettings.Hertz); DrawString($"Motor Torque = {torque}"); ImGui.SetNextWindowPos(new Vector2(10.0f, 100.0f)); ImGui.SetNextWindowSize(new Vector2(200.0f, 100.0f)); ImGui.Begin("Joint Controls", ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize); if (ImGui.Checkbox("Limit", ref _enableLimit)) { _joint.EnableLimit(_enableLimit); } if (ImGui.Checkbox("Motor", ref _enableMotor)) { _joint.EnableMotor(_enableMotor); } if (ImGui.SliderFloat("Speed", ref _motorSpeed, -100.0f, 100.0f, "%.0f")) { _joint.SetMotorSpeed(_motorSpeed); } ImGui.End(); }
/// <inheritdoc /> public override void OnKeyDown(KeyboardKeyEventArgs key) { switch (key.Key) { case Key.A: _spring1.SetMotorSpeed(_speed); break; case Key.S: _spring1.SetMotorSpeed(0.0f); break; case Key.D: _spring1.SetMotorSpeed(-_speed); break; } }
/// <inheritdoc /> public override void OnKeyDown(KeyInputEventArgs keyInput) { switch (keyInput.Key) { case KeyCodes.A: _spring1.SetMotorSpeed(_speed); break; case KeyCodes.S: _spring1.SetMotorSpeed(0.0f); break; case KeyCodes.D: _spring1.SetMotorSpeed(-_speed); break; } }
protected override void OnStep() { var p = TestSettings.Camera.transform.position; p.x = _car.GetPosition().X; TestSettings.Camera.transform.position = p; if (Input.GetKeyDown(KeyCode.A)) { _spring1.SetMotorSpeed(_speed); } if (Input.GetKeyDown(KeyCode.S)) { _spring1.SetMotorSpeed(0.0f); } if (Input.GetKeyDown(KeyCode.D)) { _spring1.SetMotorSpeed(-_speed); } }
/// <inheritdoc /> protected override void PreUpdate() { DrawString("Keys: left = a, brake = s, right = d, hz down = q, hz up = e"); DrawString($"frequency = {_hz} hz, damping ratio = {_zeta}"); var p = MainCamera.transform.position; p.x = _car.GetPosition().X; MainCamera.transform.position = p; if (Input.GetKeyDown(KeyCode.A)) { _spring1.SetMotorSpeed(_speed); } if (Input.GetKeyDown(KeyCode.S)) { _spring1.SetMotorSpeed(0.0f); } if (Input.GetKeyDown(KeyCode.D)) { _spring1.SetMotorSpeed(-_speed); } if (Input.GetKeyDown(KeyCode.Q)) { _hz = Math.Max(0.0f, _hz - 1.0f); _spring1.SetSpringFrequencyHz(_hz); _spring2.SetSpringFrequencyHz(_hz); } if (Input.GetKeyDown(KeyCode.E)) { _hz += 1.0f; _spring1.SetSpringFrequencyHz(_hz); _spring2.SetSpringFrequencyHz(_hz); } }