limitSpeed: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Arma[ _]3(\|.*)\]\]" to "{{GameCategory|arma3|Scripting Commands}}")
(Default value correction)
 
(50 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma1 |Game name=
|game1= arma1
|version1= 1.00


|1.00|Game version=
|game2= arma2
|version2= 1.00


|gr1= Unit Control |GROUP1=
|game3= arma2oa
|version3= 1.50


|gr2= Object Manipulation |GROUP2=
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


| Limit speed of given vehicle or person to given value (in km/h). |DESCRIPTION=
|game5= arma3
____________________________________________________________________________________________
|version5= 0.50


| objectName '''limitSpeed''' speed |SYNTAX=
|gr1= Unit Control


|p1= objectName: [[Object]] |PARAMETER1=
|gr2= Object Manipulation


|p2= speed: [[Number]] |PARAMETER2=
|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.


| [[Nothing]] |RETURNVALUE=
|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.
____________________________________________________________________________________________


|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.)
|s1= objectName [[limitSpeed]] speed
_this [[setVariable]] ["speedLimit", 200];
_nul = _this [[spawn]] {
[[while]] {[[canMove]] _this} [[do]] {
_this [[limitSpeed]] (_this [[getVariable]] "speedLimit");
[[sleep]] 0.1;
};
};</code> |EXAMPLE1=


|x2 = <code>["SpeedObserver","onEachFrame",{[[hintSilent]] [[format]] ["%1",[[speed]] [[vehicle]] MyVehicle]},[]] [[call]] [[BIS_fnc_addStackedEventHandler]];
|p1= objectName: [[Object]]
[[sleep]] 10;
MyVehicle [[limitSpeed]] 5; //Watch the effect of this command.
</code> | = Example 2
____________________________________________________________________________________________


| [[speed]] |SEEALSO=
|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]]


<h3 style="display:none">Notes</h3>
|x1= <sqf>
<dl class="command_description">
leader player limitSpeed 5; // set to walking speed
<!-- Note Section BEGIN -->
sleep 30;
<dd class="notedate">Posted on 9 February 2008
leader player limitSpeed (2 * getNumber(configOf leader player >> "maxSpeed")); // remove the limit
<dt class="note>'''[[User:Kronzky|Kronzky]]'''
</sqf>
<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 class="notedate">Posted on 29 July 2014
|x2= <sqf>
<dt class="note>'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''
addMissionEventHandler ["OnEachFrame", { hintSilent format ["myVehicle's speed: %1 km/h", speed myVehicle toFixed 2] }];
<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.
sleep 5;
<!-- Note Section END -->
myVehicle limitSpeed 5;
</dl>
</sqf>


<h3 style="display:none">Bottom Section</h3>
|x3= <sqf>
[[Category:Scripting Commands|LIMITSPEED]]
// it was necessary to use limitSpeed repeatedly before Arma 3 1.24
{{GameCategory|arma1|Scripting Commands}}
_this setVariable ["speedLimit", 50];
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
_this spawn {
{{GameCategory|arma3|Scripting Commands}}
while { sleep 0.1; canMove _this } do
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
{
_this limitSpeed (_this getVariable "speedLimit");
};
};
sleep 10;
_this setVariable ["speedLimit", 100]; // update the speed limit
</sqf>
 
|seealso= [[speed]] [[setCruiseControl]]
}}

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