Skip to content

Commit

Permalink
[game] enabled wasd controls for the car (not just arrows) so that th…
Browse files Browse the repository at this point in the history
…e control scheme doesn't change when switching from the camera to the car view and vice versa
  • Loading branch information
PanosK92 committed Dec 2, 2024
1 parent 1f166c5 commit bd489ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions runtime/Game/Car.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ namespace Spartan
m_parameters.break_until_opposite_torque = false;
}

if (Input::GetKey(KeyCode::Arrow_Up) || Input::GetGamepadTriggerRight() != 0.0f)
if (Input::GetKey(KeyCode::W) || Input::GetKey(KeyCode::Arrow_Up) || Input::GetGamepadTriggerRight() != 0.0f)
{
if (m_parameters.movement_direction == CarMovementState::Backward)
{
Expand All @@ -682,7 +682,7 @@ namespace Spartan
m_parameters.throttle = 1.0f;
}
}
else if (Input::GetKey(KeyCode::Arrow_Down) || Input::GetGamepadTriggerLeft() != 0.0f)
else if (Input::GetKey(KeyCode::S) || Input::GetKey(KeyCode::Arrow_Down) || Input::GetGamepadTriggerLeft() != 0.0f)
{
if (m_parameters.movement_direction == CarMovementState::Forward)
{
Expand All @@ -706,11 +706,11 @@ namespace Spartan
{
float steering_angle_target = 0.0f;

if (Input::GetKey(KeyCode::Arrow_Left) || Input::GetGamepadThumbStickLeft().x < 0.0f)
if (Input::GetKey(KeyCode::A) || Input::GetKey(KeyCode::Arrow_Left) || Input::GetGamepadThumbStickLeft().x < 0.0f)
{
steering_angle_target = -tuning::steering_angle_max;
}
else if (Input::GetKey(KeyCode::Arrow_Right) || Input::GetGamepadThumbStickLeft().x > 0.0f)
else if (Input::GetKey(KeyCode::D) || Input::GetKey(KeyCode::Arrow_Right) || Input::GetGamepadThumbStickLeft().x > 0.0f)
{
steering_angle_target = tuning::steering_angle_max;
}
Expand Down Expand Up @@ -768,7 +768,7 @@ namespace Spartan
m_parameters.body->applyCentralForce(drag_bullet);
}

// breaking
// braking
{
float breaking = Input::GetKey(KeyCode::Space) ? 1.0f : 0.0f;
breaking = m_parameters.break_until_opposite_torque ? 1.0f : breaking;
Expand Down
4 changes: 2 additions & 2 deletions runtime/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,14 +1098,14 @@ namespace Spartan
// the camera is a child of physics capsule
bool outside_the_car = m_default_physics_body_camera->GetChildrenCount() != 0;

if (outside_the_car)
if (outside_the_car) // move inside
{
Entity* camera = m_default_physics_body_camera->GetChildByName("component_camera");
camera->SetParent(m_default_car);
camera->SetPositionLocal(Vector3(0.5f, 1.8f, -0.6f));
camera->SetRotationLocal(Quaternion::Identity);
}
else
else // move outside
{
Entity* camera = m_default_car->GetChildByName("component_camera");
camera->SetParent(m_default_physics_body_camera);
Expand Down

0 comments on commit bd489ef

Please sign in to comment.