Jump to content

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


gromit190

Recommended Posts

Hello,

 

 

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,

gromit190

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

end

if Heading < 0 then

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

end

return Heading

end

end

 

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


Edited by sea2sky

i5-9600K@4.8GHz 32Gb DDR4 Asus TUF rtx3080 OC Quest Pro 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...