Jump to content

trying to get Velocity value


Recommended Posts


I have a script where I am trying to get the velocity of a vehicle. I have been trying to use getVelocity() to no avail, but what is weird is that :getLife() does return the proper value.


So, why would: player.Unit:getLife() work where player.Unit:getVelocity() will not. They are in the same spot in the code, switching one value for the other.


Thanks for any help you can provide,


Link to comment
Share on other sites

getVelocity() returns a table of a units velocity vector. If you are using mist you can use mist.vec.mag() on the value returned from getVelocity() to use velocity as a numerical value.

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Whoot! its returning a value, but seems to be little less then half of the F2 Knots indication;

Example, Flying over trigger in P51-

In cockpit: 250 mph

F2 indicates: 216 knots

Value from mist.vec.mag(player.Unit:getVelocity()) - 111.0485


Looks like if I multiply times 1.95 will get a value close enough to work with.


Thanks Grimes!

Link to comment
Share on other sites

111.0485 are m/s, which is exactly about 215 knots (nautical miles/hour), that also are 248 ground miles per hour.


Everything seems correct, if the P51 indicator in ground miles/h and not in kn.


Author of DSMC, mod to enable scenario persistency and save updated miz file

Stable version & site: https://dsmcfordcs.wordpress.com/

Openbeta: https://github.com/Chromium18/DSMC


The thing is, helicopters are different from planes. An airplane by it's nature wants to fly, and if not interfered with too strongly by unusual events or by a deliberately incompetent pilot, it will fly. A helicopter does not want to fly. It is maintained in the air by a variety of forces in opposition to each other, and if there is any disturbance in this delicate balance the helicopter stops flying; immediately and disastrously.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...