Skip to content

Commit

Permalink
Fix spawned cars sliding down slopes (#61)
Browse files Browse the repository at this point in the history
* Put GM-spawned cars into first gear

* Correct comment
  • Loading branch information
Kexanone authored Dec 12, 2024
1 parent a7f0f7b commit 7664e25
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,29 @@ modded class SCR_PlacingEditorComponent : SCR_BaseEditorComponent
protected void GME_OnPlaceEntityServer(RplId prefabID, SCR_EditableEntityComponent entity, int playerID)
{
GME_Modules_Base module = GME_Modules_Base.Cast(entity.GetOwner());
// Handle placement of modules
if (module)
{
GME_OnModulePlacedServer(module, playerID);
}
// Put wheeled vehicles in first gear to prevent them sliding down slopes
else if (SCR_EditableVehicleComponent.Cast(entity))
{
Vehicle vehicle = Vehicle.Cast(entity.GetOwner());
if (!vehicle)
return;

CarControllerComponent controller = CarControllerComponent.Cast(vehicle.GetVehicleController());
if (!controller)
return;

VehicleWheeledSimulation simulation = controller.GetSimulation();
if (!simulation)
return;

// Gear mapping: 0 => R, 1 => N, 2 => D/1, ...
simulation.SetGear(2);
}
}

//------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 7664e25

Please sign in to comment.