setCruiseControl: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
(Remove "you", Fix description)
Line 11: Line 11:
|eff= local
|eff= local


|descr= Limits or sets a player-controlled vehicle's speed through cruise control.<br>
|descr= Limits or sets '''[[local]] [[player]]-controlled''' vehicle's speed through cruise control.
Speed Limiter and Cruise Control are implemented using a PID controller overwriting the vehicles thrust input.<br>
 
Cruise control is implemented as a speed limiter that simulates 100% thrust input by the player.<br>
{{Feature|informative|
If you apply brakes while cruise control is enabled, the cruise control (and speed limit) will automatically disengage.<br>
* this command only works on CarX, TankX, ShipX simulation vehicles
If (deltaSpeed > setpoint*20% && speed > setpoint) the vehicle will automatically apply 50% brakes to try to get back down to the setpoint.<br>
* this command is implemented using a PID controller overwriting the vehicle's thrust/brakes input
If (deltaSpeed > setpoint*20% && speed < setpoint) the vehicle will always apply 100% thrust.<br><br>
{{Feature|important|
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>
You should only call ''setCruiseControl'' to '''change''' the setpoint.<br><br>
This command only works for:
* The local player
* CarX, TankX and ShipX simulated vehicles
* Forward speeds (positive ''speed'')
}}
}}
{{{!}} class="wikitable"
! Speed Limiter
! Cruise Control
{{!}}- style="vertical-align: top"
{{!}}
* the vehicle does not accelerate by itself
* manually accelerating is required to move forward
* accelerating beyond set speed limit is restricted by the PID controller
* applying brakes does not disable Speed Limiter
* behaviour:
** if the speed is over 120% the set limit, the vehicle will brake
** if the speed is below 80% the set limit, the full range of acceleration is available
** between 80 and 120%, the PID controller manages the acceleration input
{{!}}
* the vehicle accelerates by itself
* manually accelerating is possible
* accelerating above set speed limit is possible
* applying brakes disables Cruise Control
* behaviour:
** if the speed is over 120% the set limit, the vehicle will apply 100% of braking
** if the speed is below 80% the set limit, the vehicle will apply 100% of acceleration
** between 80 and 120%, the PID controller manages the speed
{{!}}}
{{Feature|important|This command should only be called to ''change'' values and '''not''' be called every frame, as it resets the PID controller.}}


|gr1= Unit Control
|gr1= Unit Control
Line 33: Line 50:
|s1= vehicle [[setCruiseControl]] [speed, autoThrust]
|s1= vehicle [[setCruiseControl]] [speed, autoThrust]


|p1= vehicle: [[Object]] - The vehicle to limit
|p1= vehicle: [[Object]] - the vehicle to limit; [[local]] [[player]]'s vehicle ({{ic|[[vehicle]] [[player]]}})


|p2= 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
|p2= 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


|p3= autoThrust: [[Boolean]]
|p3= autoThrust: [[Boolean]]
* [[true]] - Cruise control. The vehicle will maintain this speed until brakes is applied or driver dies or leaves the vehicle
* [[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
* [[false]] - Speed Limiter: the vehicle will not accelerate above set speed


|r1= [[Nothing]]
|r1= [[Nothing]]

Revision as of 13:10, 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 local player-controlled vehicle's speed through cruise control.
  • this command only works on CarX, TankX, ShipX simulation vehicles
  • this command is implemented using a PID controller overwriting the vehicle's thrust/brakes input
Speed Limiter Cruise Control
  • the vehicle does not accelerate by itself
  • manually accelerating is required to move forward
  • accelerating beyond set speed limit is restricted by the PID controller
  • applying brakes does not disable Speed Limiter
  • behaviour:
    • if the speed is over 120% the set limit, the vehicle will brake
    • if the speed is below 80% the set limit, the full range of acceleration is available
    • between 80 and 120%, the PID controller manages the acceleration input
  • the vehicle accelerates by itself
  • manually accelerating is possible
  • accelerating above set speed limit is possible
  • applying brakes disables Cruise Control
  • behaviour:
    • if the speed is over 120% the set limit, the vehicle will apply 100% of braking
    • if the speed is below 80% the set limit, the vehicle will apply 100% of acceleration
    • between 80 and 120%, the PID controller manages the speed
This command should only be called to change values and not be called every frame, as it resets the PID controller.
Groups:
Unit ControlObject Manipulation

Syntax

Syntax:
vehicle setCruiseControl [speed, autoThrust]
Parameters:
vehicle: Object - the vehicle to limit; local player's vehicle (vehicle player)
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