limitSpeed: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
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.


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


|p2= speed: [[Number]]
|p2= speed: [[Number]] - in km/h; set to {{hl|-1}} (or any <= 0 value) to remove the limit


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


|x1= <sqf>// 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 -1; // remove the limit
</sqf>
 
|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");
_this limitSpeed (_this getVariable "speedLimit");
sleep 0.1;
};
};
};</sqf>
};
 
|x2= <sqf>["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.</sqf>
_this setVariable ["speedLimit", 100]; // update the speed limit
</sqf>


|seealso= [[speed]]
|seealso= [[speed]]
}}
<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>
{{Note
|user= fusselwurm
|timestamp= 20220806183948
|text= use value <= 0 to unset
}}
}}

Revision as of 10:20, 7 August 2022

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.
Groups:
Unit ControlObject Manipulation

Syntax

Syntax:
objectName limitSpeed speed
Parameters:
objectName: Object
speed: Number - in km/h; set to -1 (or any <= 0 value) to remove the limit
Return Value:
Nothing

Examples

Example 1:
leader player limitSpeed 5; // set to walking speed sleep 30; leader player limitSpeed -1; // 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

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