limitSpeed: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^<]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^<]*) *<\/code>" to "<code>$1$2$3</code>")
(Default value correction)
 
(12 intermediate revisions by 2 users not shown)
Line 20: Line 20:
|gr2= Object Manipulation
|gr2= Object Manipulation


|descr= Limit speed of given vehicle or person to given value (in km/h).
|descr= Limit the speed of an AI-driven vehicle or AI person to given value. It has continuous effect and AI will not break through the speed limitation until one is contacted, engaged or regrouped.
 
|pr= Since {{GVI|tkoh|1.00|size= 0.75}} and as of {{GVI|arma3|2.14|size= 0.75}}, using any negative value on a helicopter will not reset the speed limit, but will force it to fly in reverse.


|s1= objectName [[limitSpeed]] speed
|s1= objectName [[limitSpeed]] speed
Line 26: Line 28:
|p1= objectName: [[Object]]
|p1= objectName: [[Object]]


|p2= speed: [[Number]]
|p2= speed: [[Number]] - in km/h; By default, it's {{hl|2 * maxSpeed}} of the vehicle/unit (which is defined in config). See Example 1.


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


|x1= <code>// Adjust "speedLimit" variable to change limited speed. (A3 1.24 we don't need loop for a continus effect, limitSpeed alone is enough.)
|x1= <sqf>
_this setVariable ["speedLimit", 200];
leader player limitSpeed 5; // set to walking speed
_nul = _this spawn {
sleep 30;
[[while]] {[[canMove]] _this} [[do]] {
leader player limitSpeed (2 * getNumber(configOf leader player >> "maxSpeed")); // remove the limit
_this [[limitSpeed]] (_this [[getVariable]] "speedLimit");
</sqf>
[[sleep]] 0.1;
 
|x2= <sqf>
addMissionEventHandler ["OnEachFrame", { hintSilent format ["myVehicle's speed: %1 km/h", speed myVehicle toFixed 2] }];
sleep 5;
myVehicle limitSpeed 5;
</sqf>
 
|x3= <sqf>
// it was necessary to use limitSpeed repeatedly before Arma 3 1.24
_this setVariable ["speedLimit", 50];
_this spawn {
while { sleep 0.1; canMove _this } do
{
_this limitSpeed (_this getVariable "speedLimit");
};
};
};</code>
};
 
|x2= <code>["SpeedObserver","onEachFrame",{hintSilent format ["%1",speed vehicle MyVehicle]},[]] call BIS_fnc_addStackedEventHandler;
sleep 10;
sleep 10;
MyVehicle limitSpeed 5; // watch the effect of this command.</code>
_this setVariable ["speedLimit", 100]; // update the speed limit
</sqf>


|seealso= [[speed]]
|seealso= [[speed]] [[setCruiseControl]]
}}
}}
<dl class="command_description">
<dt></dt>
<dd class="notedate">Posted on 9 February 2008</dd>
<dt class="note">[[User:Kronzky|Kronzky]]</dt>
<dd class="note">(A1 1.08.5163)Has only an ''temporary'' effect on the vehicle specified (i.e. vehicle goes back to its previous speed right away). So, in order for this command to have a ''real'', noticeable effect, it would have to be issued continuously (e.g. via a script loop, but in A3 1.24 it is unnecessary).
</dd>
<dt><dt>
<dd class="notedate">Posted on 29 July 2014</dd>
<dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]</dt>
<dd class="note">(A3 1.24)To clarify, [[limitSpeed]] only do effect on non-player controlled AI units, it has continuous effect and AI won’t break through the speed limitation until one is contacted, engaged or regrouped.
</dd>
</dl>

Latest revision as of 18:09, 28 March 2024

Hover & click on the images for description

Description

Description:
Limit the speed of an AI-driven vehicle or AI person to given value. It has continuous effect and AI will not break through the speed limitation until one is contacted, engaged or regrouped.
Problems:
Since tkoh logo small.png1.00 and as of Arma 3 logo black.png2.14, using any negative value on a helicopter will not reset the speed limit, but will force it to fly in reverse.
Groups:
Unit ControlObject Manipulation

Syntax

Syntax:
objectName limitSpeed speed
Parameters:
objectName: Object
speed: Number - in km/h; By default, it's 2 * maxSpeed of the vehicle/unit (which is defined in config). See Example 1.
Return Value:
Nothing

Examples

Example 1:
leader player limitSpeed 5; // set to walking speed sleep 30; leader player limitSpeed (2 * getNumber(configOf leader player >> "maxSpeed")); // remove the limit
Example 2:
addMissionEventHandler ["OnEachFrame", { hintSilent format ["myVehicle's speed: %1 km/h", speed myVehicle toFixed 2] }]; sleep 5; myVehicle limitSpeed 5;
Example 3:
// it was necessary to use limitSpeed repeatedly before Arma 3 1.24 _this setVariable ["speedLimit", 50]; _this spawn { while { sleep 0.1; canMove _this } do { _this limitSpeed (_this getVariable "speedLimit"); }; }; sleep 10; _this setVariable ["speedLimit", 100]; // update the speed limit

Additional Information

See also:
speed setCruiseControl

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