Jump to content

How to change heading of a spawned unit via script ? (mist)


Recommended Posts

Posted (edited)

Im using mist.cloneGroup to spawn new units and mist.teleportTopPoint to position them. But how can I change their heading / rotation ?

 

this doesnt work

    local unit = mist.getGroupData(grp).units[1]
    local newHeading = Heading + math.pi
    unit.heading = newHeading

Thanks

Edited by winghunter

DCS Web Editor - New 3D Mission Editor for DCS that runs in your browser

DCS Web Viewer free browser based mission planner

dcs web editor signature2.png
4090 RTX, 13700KF, water cooled, Quest 3

 

Posted
12 minutes ago, Wizxrd said:
local newHeading = heading*math.pi/180

That should do the trick!

Thanks though i forgot to mention Heading is already in radians, as i get it form

    local Heading = mist.getHeading(player)

DCS Web Editor - New 3D Mission Editor for DCS that runs in your browser

DCS Web Viewer free browser based mission planner

dcs web editor signature2.png
4090 RTX, 13700KF, water cooled, Quest 3

 

Posted (edited)
5 hours ago, winghunter said:

Im using mist.cloneGroup to spawn new units and mist.teleportTopPoint to position them. But how can I change their heading / rotation ?...

 

If you clone a group, only the datas of original group will be used. No way to change them.
If you want to change them, you need to spawn a new group with mist.dynAdd(), instead of cloning. (change groupName if you don't want to destroy previous group at spawn)
Code example to randomize headings at spawn of units of a ground group named 'test' :

local GPdata = mist.getGroupData('test')
for i = 1, #GPdata.units do
GPdata.units[i].heading = mist.utils.toRadian(mist.random(360))
end
mist.dynAdd(GPdata)

 

Edited by toutenglisse
Posted
10 hours ago, toutenglisse said:

If you clone a group, only the datas of original group will be used. No way to change them.
If you want to change them, you need to spawn a new group with mist.dynAdd(), instead of cloning. (change groupName if you don't want to destroy previous group at spawn)
Code example to randomize headings at spawn of units of a ground group named 'test' :

local GPdata = mist.getGroupData('test')
for i = 1, #GPdata.units do
GPdata.units[i].heading = mist.utils.toRadian(mist.random(360))
end
mist.dynAdd(GPdata)

 

 

Thanks, i've updated to latest mist and tried this approach. It seems however that heading makes no difference to spawning air units, they will always face north even though their heading data says different.

DCS Web Editor - New 3D Mission Editor for DCS that runs in your browser

DCS Web Viewer free browser based mission planner

dcs web editor signature2.png
4090 RTX, 13700KF, water cooled, Quest 3

 

Posted
1 hour ago, winghunter said:

Thanks, i've updated to latest mist and tried this approach. It seems however that heading makes no difference to spawning air units, they will always face north even though their heading data says different.

heading is only for ground unit. Air spawned aircraft heading is defined by next wpt direction (same as in mission editor).

  • Recently Browsing   0 members

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