Jump to content

Converting a units orientation to a "heading"? (Script help)

Recommended Posts




The "addGroup" function takes a "heading" as an argument to position the unit when spawning it. I need this heading to be the same as heading as a previously spawned unit. I reckon I get the heading of the previously spawned unit from this function. But how do I convert it to a single number "heading" needed for the addgroup function?



Best regards,


Link to comment
Share on other sites

function getHeading(unitpos, northCorrection)

if unitpos then

local Heading = math.atan2(unitpos.x.z, unitpos.x.x)

if northCorrection then

Heading = Heading + northCorrection


if Heading < 0 then

Heading = Heading + 2*math.pi -- convert to rad


return Heading




You may want to provide northCorrection for a true north heading.

Edited by sea2sky

i5-9600K@4.8GHz z390 Aorus Pro 32Gb DDR4 1080ti Rift CV1 Warthog on Virpil base

Link to comment
Share on other sites

  • 1 month later...
Thank you!


Can you please eloborate on why I need correction for a "true" north heading?


In F10 map, you have geographic North... In aircrafts, usually you have magnetic North... the correction depends on where are you flying. The game gives you Geographic, usually, since it is based on map.

Caucasus magnetic = geographic - 6°

Nevada magnetic = geographic - 11°

Link to comment
Share on other sites


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...