setCruiseControl: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " |descr=" to " |branch= dev |descr=")
m (Text replacement - "(\|[pr][0-9]+ *= *[^-]+) *- *C([a-eg-z])" to "$1 - c$2")
 
(11 intermediate revisions by 3 users not shown)
Line 5: Line 5:


|arg= local
|arg= local
|eff= local
|eff= local


|branch= dev
|descr= Limits or sets '''[[local]] [[player]]-controlled''' vehicle's speed through cruise control.


|descr= Limits or set a player-controlled vehicle's speed through cruise control. {{Feature|important|This command only works:
{{Feature|informative|
* for the local player
* this command only works on CarX, TankX, ShipX simulation vehicles
* on CarX, TankX and ShipX simulated vehicles
* this command is implemented using a PID controller overwriting the vehicle's thrust/brakes input
}}
}}
{{{!}} 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 apply 100% of braking and limit acceleration to 0%
** if the speed is below 80% the set limit, the acceleration and braking are untouched
** between 80 and 120%, the PID controller limits the acceleration and applies brakes if required
{{!}}
* 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 20: Line 47:
|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 (<sqf inline>vehicle player</sqf>)


|p2= speed: [[Number]] - desired/top speed in km/h. 0 to disable any setting. Negative values for reverse gear speed
|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]]


|x1= <code>[[vehicle]] [[player]] [[setCruiseControl]] [50, [[true]]]; {{cc|sets cruise control to 50 km/h}}</code>
|x1= <sqf>vehicle player setCruiseControl [50, true]; // sets cruise control to 50 km/h</sqf>
 
|x2= <code>[[vehicle]] [[player]] [[setCruiseControl]] [5, [[false]]]; {{cc|limits player's vehicle speed to 5 km/h}}</code>
 
|x3= <code>[[vehicle]] [[player]] [[setCruiseControl]] [-5, [[true]]]; {{cc|will make the vehicle go backwards}}</code>


|x4= <code>[[vehicle]] [[player]] [[setCruiseControl]] [-5, [[false]]]; {{cc|will make the vehicle go backwards too (speed cannot be over -5 km/h)}}</code>
|x2= <sqf>vehicle player setCruiseControl [5, false]; // limits player's vehicle speed to 5 km/h</sqf>


|seealso= [[getCruiseControl]] [[limitSpeed]] [[forceSpeed]] [[setAirplaneThrottle]]
|seealso= [[getCruiseControl]] [[limitSpeed]] [[forceSpeed]] [[setAirplaneThrottle]]
}}
}}

Latest revision as of 13:59, 8 November 2023

Hover & click on the images for description

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 apply 100% of braking and limit acceleration to 0%
    • if the speed is below 80% the set limit, the acceleration and braking are untouched
    • between 80 and 120%, the PID controller limits the acceleration and applies brakes if required
  • 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