gromit190 Posted September 19, 2016 Posted September 19, 2016 Hi The title says it all. The "addGroup" function (http://wiki.hoggit.us/view/DCS_func_addGroup) takes "X" and "Y" to position the unit I'm tring to add. The problem is that I know I want it to spawn at N42 13.620 E42 39.518. So how do I convert these coordinates to X/Y? Cheers from Norway Autonomous ground AI project
gromit190 Posted September 19, 2016 Author Posted September 19, 2016 (edited) Tried this code, but I the LAV spawned somewhere faaaaar out north west local coordinate = coord.LLtoLO(42.13982, 42.39503) local lat, long, alt = coord.LOtoLL(coordinate) local msg = lat .. ", " .. long .. "\n" .. coordinate.x .. ", " .. coordinate.y .. ", " .. coordinate.z trigger.action.outText(msg, 10) local groupData = { ["visible"] = false, ["taskSelected"] = true, ["route"] = { }, -- end of ["route"] ["groupId"] = 2, ["tasks"] = { }, -- end of ["tasks"] ["hidden"] = false, ["units"] = { [1] = { ["type"] = "LAV-25", ["transportable"] = { ["randomTransportable"] = false, }, -- end of ["transportable"] ["x"] = coordinate.x, ["y"] = coordinate.y, ["z"] = coordinate.z, ["unitId"] = 2, ["skill"] = "Excellent", ["name"] = "Ground Unit1", ["playerCanDrive"] = true, ["heading"] = 0.28605144170571, }, -- end of [1] }, -- end of ["units"] ["x"] = coordinate.x, ["y"] = coordinate.y, ["z"] = coordinate.z, ["name"] = "Ground Group", ["start_time"] = 0, ["task"] = "Ground Nothing", } -- end of [1] coalition.addGroup(country.id.USA, Group.Category.GROUND, groupData) EDIT: This is where it is spawning: Edited September 20, 2016 by gromit190 Autonomous ground AI project
FSFIan Posted September 19, 2016 Posted September 19, 2016 Read up on the difference between vec2 and vec3. Vec2.x = Vec3.x Vec2.y = Vec3.z Ground unit spawning uses 2D coordinates, so x = coordinate.x, y = coordinate.z! DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
Grimes Posted September 19, 2016 Posted September 19, 2016 Also there is no "z" coordinate, it is labeled as "alt" and only applies to aircraft. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Wrecking Crew Posted September 20, 2016 Posted September 20, 2016 Hi ...I know I want it to spawn at... Cheers from Norway You know where you want it to spawn. Go into a mission and press LCntrl-Y, Info Bar Toggle, and it will cycle through the coordinate systems. Cheers from Colorado! Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.
gromit190 Posted September 20, 2016 Author Posted September 20, 2016 (edited) Thanks guys! It's strange, even though I map the Y coordinate to Z, it still seems very "off" from my lat/long coordinates. You know where you want it to spawn. Go into a mission and press LCntrl-Y, Info Bar Toggle, and it will cycle through the coordinate systems. Cheers from Colorado! Strange, the info bar comes up, but it doesn't change coordinate systems when I toggle it again. On the third toggle it disappears again so there's obviously some toggle inbetween... But all I see is lat/long coordinates. Okay so I tried to figure what lat/long coordinates that are correct to get the group to spawn where I want. This is the code: -- Initialization if (initialized == nil) then initialized = true end function test() local coordinate3 = coord.LLtoLO(42.24, 42.66) local coordinate2 = { x = coordinate3.x, y = coordinate3.z } local lat, long, alt = coord.LOtoLL(coordinate3) local msg = coordinate2.x .. "," .. coordinate2.y trigger.action.outText(msg, 1) local groupData = { ["visible"] = false, ["taskSelected"] = true, ["route"] = { }, -- end of ["route"] ["groupId"] = 2, ["tasks"] = { }, -- end of ["tasks"] ["hidden"] = false, ["units"] = { [1] = { ["type"] = "LAV-25", ["transportable"] = { ["randomTransportable"] = false, }, -- end of ["transportable"] ["x"] = coordinate2.x, ["y"] = coordinate2.y, ["unitId"] = 2, ["skill"] = "Excellent", ["name"] = "Ground Unit1", ["playerCanDrive"] = true, ["heading"] = 0.28605144170571, }, -- end of [1] }, -- end of ["units"] ["name"] = "Ground Group", ["start_time"] = 0, ["task"] = "Ground Nothing", } -- end of [1] coalition.addGroup(country.id.USA, Group.Category.GROUND, groupData) end test(); So now it's spawning in the correct location, but why can't I use the lat/long coordinates that I read from the F10 map? See where it spawned: EDIT: and yes, my mouse pointer is positioned directly above the unit Edited September 21, 2016 by gromit190 Autonomous ground AI project
FSFIan Posted September 20, 2016 Posted September 20, 2016 coord.LLtoLO takes latitude and longitute in (decimal) degrees. The display in the DCS map shows degrees and (decimal) minutes. latitude of 42.24 degrees: 42 degrees and (60 * 0.24) = 14.400 minutes longitude of 42.66 degrees: 42 degrees and (60 * 0.66) = 39.600 minutes To convert the other way, from coordinates displayed in the DCS map to parameters for coord.LLtoLO: latitude of 42 degrees and 14.4 minutes: (42 + (14.4/60)) = 42.24 longitude of 42 degrees and 39.6 minutes: (42 + (39.6/60)) = 42.66 DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
gromit190 Posted November 8, 2016 Author Posted November 8, 2016 Thank you very much, guys :) Autonomous ground AI project
Recommended Posts