LUA - Create RP relative to a unit from another side
Posted: Mon Feb 20, 2023 8:58 am
Why can't I assign relative reference points to a unit that is not on my side from lua, but from the game I can?
In the sample scen I have two sides BLUE and _BLUE, _BLUE is omniscient and wanna to create RP around the aircraft. Creating first the RP an then making relatives to the aircraft works as charms, but from Lua I can't.
Reading the docs it even says explicitly that the PR and the unit to which it is relative must be on the same side.
Trying to do it as from the game, creating first the area and then making them relative through SetReferencePoint doesn't work either.
In the sample scen I have two sides BLUE and _BLUE, _BLUE is omniscient and wanna to create RP around the aircraft. Creating first the RP an then making relatives to the aircraft works as charms, but from Lua I can't.
Reading the docs it even says explicitly that the PR and the unit to which it is relative must be on the same side.
Code: Select all
function getUnit()
local unit = ScenEdit_SelectedUnits().units[1]
return ScenEdit_GetUnit({guid=unit.guid})
end
local unit = getUnit()
local distance = 20
local steps = 20
for i=0,359,steps do
local coordinates=World_GetPointFromBearing({latitude=unit.latitude, longitude=unit.longitude, bearing=i, distance=distance})
local rp = ScenEdit_AddReferencePoint( {side='_BLUE', relativeTo=unit.guid, bearingType=0, latitude=coordinates.latitude, longitude=coordinates.longitude,highlighted=false})
end