limitSpeed: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(Default value correction)
 
(71 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


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


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


| Limit speed of given vehicle or person to given value (in km/h). |= Description
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| objectName '''limitSpeed''' speed |= Syntax
|game4= tkoh
|version4= 1.00


|p1= objectName: [[Object]] |= Parameter 1
|game5= arma3
|version5= 0.50


|p2= speed: [[Number]] |= Parameter 2
|gr1= Unit Control


| [[Nothing]] |= Return value
|gr2= Object Manipulation
____________________________________________________________________________________________


|x1= <pre>// Adjust "speedLimit" variable to change limited speed
|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.
this setVariable ["speedLimit", 200];
 
nul = this spawn {
|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.
while {canMove _this} do {
 
_this limitSpeed (_this getVariable "speedLimit");
|s1= objectName [[limitSpeed]] speed
sleep 0.1;
};
};</pre> |= Example 1
____________________________________________________________________________________________


| [[speed]] |= See also
|p1= objectName: [[Object]]


}}
|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.


<h3 style="display:none">Notes</h3>
|r1= [[Nothing]]
<dl class="command_description">
<!-- Note Section BEGIN -->


<dd class="notedate">Posted on 28 July 2013
|x1= <sqf>
<dt class="note>'''[[User:Will|Will]]'''
leader player limitSpeed 5; // set to walking speed
<dd class="note">This command has no effect (doesnt do anything) in Arma3 (V1.24) - Reported to BI: http://feedback.arma3.com/view.php?id=19974
sleep 30;
leader player limitSpeed (2 * getNumber(configOf leader player >> "maxSpeed")); // remove the limit
</sqf>


<dd class="notedate">Posted on 9 February 2008
|x2= <sqf>
<dt class="note>'''[[User:Kronzky|Kronzky]]'''
addMissionEventHandler ["OnEachFrame", { hintSilent format ["myVehicle's speed: %1 km/h", speed myVehicle toFixed 2] }];
<dd class="note">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). (V1.08.5163)
sleep 5;
myVehicle limitSpeed 5;
</sqf>


<!-- Note Section END -->
|x3= <sqf>
</dl>
// 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
</sqf>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[speed]] [[setCruiseControl]]
[[Category:Scripting Commands|LIMITSPEED]]
}}
[[Category:Scripting Commands ArmA|LIMITSPEED]]
[[Category:Command_Group:_Vehicle_Assignment|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

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