setCruiseControl: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Explanation about how speed limiter works and potential pitfalls)
mNo edit summary
Line 15: Line 15:
Cruise control is implemented as a speed limiter that simulates 100% thrust input by the player.<br>
Cruise control is implemented as a speed limiter that simulates 100% thrust input by the player.<br>
If you apply brakes while cruise control is enabled, the cruise control (and speed limit) will automatically disengage.<br>
If you apply brakes while cruise control is enabled, the cruise control (and speed limit) will automatically disengage.<br>
If (deltaSpeed > setpoint*20% && speed > setpoint) the vehicle will automatically apply brakes to try to get back down to the setpoint.<br>
If (deltaSpeed > setpoint*20% && speed > setpoint) the vehicle will automatically apply 50% brakes to try to get back down to the setpoint.<br>
If (deltaSpeed > setpoint*20% && speed < setpoint) the vehicle will always apply 100% thrust.<br><br>
If (deltaSpeed > setpoint*20% && speed < setpoint) the vehicle will always apply 100% thrust.<br><br>
{{Feature|important|
{{Feature|important|
Executing this script command resets the PID controller.<br>
Executing this script command resets the PID controller.<br>
Meaning if you do it every frame you will break the automatic thrust control, so don't do that.<br>
Meaning if you do it every frame you will break the automatic thrust control, so don't do that.<br>
You should only call ''setCruiseControl'' to ''change'' the setpoint.<br><br>
You should only call ''setCruiseControl'' to '''change''' the setpoint.<br><br>
This command only works for:
This command only works for:
* The local player
* The local player

Revision as of 09:36, 24 August 2021

Hover & click on the images for description
Only available in Development branch(es) until its release with Arma 3 patch v2.06.

Description

Description:
Limits or sets a player-controlled vehicle's speed through cruise control.
Speed Limiter and Cruise Control are implemented using a PID controller overwriting the vehicles thrust input.
Cruise control is implemented as a speed limiter that simulates 100% thrust input by the player.
If you apply brakes while cruise control is enabled, the cruise control (and speed limit) will automatically disengage.
If (deltaSpeed > setpoint*20% && speed > setpoint) the vehicle will automatically apply 50% brakes to try to get back down to the setpoint.
If (deltaSpeed > setpoint*20% && speed < setpoint) the vehicle will always apply 100% thrust.

Executing this script command resets the PID controller.

Meaning if you do it every frame you will break the automatic thrust control, so don't do that.
You should only call setCruiseControl to change the setpoint.

This command only works for:

  • The local player
  • CarX, TankX and ShipX simulated vehicles
  • Forward speeds (positive speed)
Groups:
Unit ControlObject Manipulation

Syntax

Syntax:
vehicle setCruiseControl [speed, autoThrust]
Parameters:
vehicle: Object - The vehicle to limit
speed: Number - Desired/top speed in km/h. 0 to disable any setting. Only positives values are valid, negative values will make the vehicle unable to move forward
autoThrust: Boolean
  • true - Cruise control. The vehicle will maintain this speed until brakes is applied or driver dies or leaves the vehicle
  • false - Speed limiter. The vehicle will not accelerate above set speed
Return Value:
Nothing

Examples

Example 1:
vehicle player setCruiseControl [50, true]; // sets cruise control to 50 km/h
Example 2:
vehicle player setCruiseControl [5, false]; // limits player's vehicle speed to 5 km/h

Additional Information

See also:
getCruiseControl limitSpeed forceSpeed setAirplaneThrottle

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note