Vehicle/SetVehicleParams

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Fixed incorrect issue number)
(This isn't specific to maxSpeed (correct me if I missed a field - this is just from memory). Apologies if this description is a bit verbose - I wanted to explain the issue very clearly)
 
Line 4: Line 4:
 
{{Note|Not all variables from the {{Struct|VehicleParams}} can be set.}}
 
{{Note|Not all variables from the {{Struct|VehicleParams}} can be set.}}
  
{{Bug|Issue=2625|This modifies the vehicle engine's "maxSpeed" to an incorrect value even when not being set by this function.}}
+
{{Bug|Issue=2625|Because this method uses miles per hour but {{ClassFunction|Vehicle|GetVehicleParams}} returns Hammer units per second, this method incorrectly modifies the vehicle engine's "boostMaxSpeed", "maxRevSpeed" and "maxSpeed" even when not explicitly set in a call to this method.
 +
 
 +
'''Workaround''': In order to retain the original values for these fields, call {{ClassFunction|Vehicle|GetVehicleParams}} yourself, convert the mentioned fields from Hammer units per second to miles per hour (1 MPH ≈ 17.6 HU/s in this case) and add them to the table passed into the call to this setter. Avoid doing this repeatedly to avoid floating point inaccuracies over time (store the ready-calculated value for next time if possible).}}
 
|Realm=Server
 
|Realm=Server
 
|IsClass=Yes
 
|IsClass=Yes

Latest revision as of 01:46, 19 December 2018

 Vehicle:SetVehicleParams( )

Description

Sets the vehicle parameters for given vehicle.

NOTE

Not all variables from the VehicleParams structure can be set.

BUG

Because this method uses miles per hour but Vehicle:GetVehicleParams returns Hammer units per second, this method incorrectly modifies the vehicle engine's "boostMaxSpeed", "maxRevSpeed" and "maxSpeed" even when not explicitly set in a call to this method.

Workaround: In order to retain the original values for these fields, call Vehicle:GetVehicleParams yourself, convert the mentioned fields from Hammer units per second to miles per hour (1 MPH ≈ 17.6 HU/s in this case) and add them to the table passed into the call to this setter. Avoid doing this repeatedly to avoid floating point inaccuracies over time (store the ready-calculated value for next time if possible).

Issue Tracker: #2625

Arguments

table params

The new new vehicle parameters. See VehicleParams structure
Personal tools
Navigation