Funcoot 10 Posted July 10, 2009 Hey guys, I'm pretty new to ArmA2 mission editing & scripting. I was wondering if someone could teach me how to limit the speed of a vehicle. I checked the wiki and I just had problems doing it myself. I also used the search function on the forums to find a solution, but no dice. Thanks in advanced. :bounce3: Share this post Link to post Share on other sites
Kabolte 10 Posted July 10, 2009 Put this in the init field of the vehicle you want to limit this forceSpeed 5.5; Obviously you could change the speed to whatever you want. 5.5 is approximately the speed at which infantry run. Share this post Link to post Share on other sites
Funcoot 10 Posted July 10, 2009 That doesn't have any effect at all sadly. :( Share this post Link to post Share on other sites
Kabolte 10 Posted July 10, 2009 I tested it and it works for me. You sure you put it in the right field? If you did, try changing the speed to 1 to make it's effects more obvious and see if that works. Share this post Link to post Share on other sites
Funcoot 10 Posted July 10, 2009 http://www.cubeupload.com/files/cb8a00notworking.png Still not working, am I doing something wrong? Also, I tried 1, still a no go. Share this post Link to post Share on other sites
Kabolte 10 Posted July 10, 2009 Oh you're trying it for a car you drive? The forceSpeed command only works with AI vehicles. I don't know how to do what you're asking, sorry. Share this post Link to post Share on other sites
kylania 568 Posted July 10, 2009 You could run a loop that checks the speed and reduces it to your wanted maximum every second or so Share this post Link to post Share on other sites
Funcoot 10 Posted July 10, 2009 You could run a loop that checks the speed and reduces it to your wanted maximum every second or so That is what I've been trying to do, but I can't seem to get it right. _governator = 1; while { _governator == 1 } do { this limitSpeed 20; }; Also tried force speed. Just not working. Share this post Link to post Share on other sites
kylania 568 Posted July 10, 2009 Here's a script that appears to work. I accept no responsiblity for the math in this, I suck at math, it's borrowed from the biki. :) Put this in the vehicles init field, setting the speed to what you want. null = [this, 60] execVM "speedlimit.sqf"; Then this is the script: ////////////////////////////////////////////////////////////////// // Function file for Armed Assault // Created by: kylania ////////////////////////////////////////////////////////////////// // Call this with the following line in the init field of the vehicle. // this = object to slow. // 60 = max speed for vehicle. // // null = [this, 60] execVM "speedlimit.sqf"; // Pull the object and speed from the execVM. _vehicle = _this select 0; _maxspeed = _this select 1; // Figure current speed. _curspeed = speed _vehicle; // If we're going to fast... if (_curspeed > _maxspeed) then { // Grab the current velocity and direction of the vehicle. _vel = velocity _vehicle; _dir = direction _vehicle; // Limit it's to bring it back down to the max amount. _speed = _curspeed - _maxspeed; // This is math I don't understand, grabbed it from the biki. :) _vehicle setVelocity [(_vel select 0)-(sin _dir*_speed),(_vel select 1)- (cos _dir*_speed),(_vel select 2)]; }; // End of if // Sleep tenth of a second, this might be too much processing. I dunno, slower and the ride get jerkier though. sleep 0.1; // Call the script again. _null = [_vehicle, _maxspeed] execVM "speedlimit.sqf"; 1 Share this post Link to post Share on other sites
Tajin 349 Posted July 10, 2009 Kylania, an less math-intensive way would be: _vehicle setVelocity [(_vel select 0)/curspeed * maxspeed,(_vel select 1)/curspeed * maxspeed,(_vel select 2)/curspeed * maxspeed]; 1 Share this post Link to post Share on other sites
Skanda 2 Posted October 20, 2016 Do you guys can help me. I would like to integrate a script into my mission with which i can limit the speed of a given ground vehicle. The vehicle is either controlled by squad AI or by the player. For example: If you press a given key when you driving, or giving a command to an AI driver of a squadmember the limit of the vehicle is set to a certain number. When you press again, the speed limiter is off. I have no scripting skills at all, so this makes it quiet difficult for me though. Tried to look at the scripts of AGM and ACE but they do not quite help me. I think if one has more clue than i, it is not a big deal. Thank you in advance Cheers Skanda Share this post Link to post Share on other sites