Question create a vessel in the right place

johnnymanly

Donator
Donator
Joined
Mar 17, 2008
Messages
179
Reaction score
116
Points
43
Location
Southwest Pennsylginia
Website
sites.google.com
I'm working on a multistage vessel but I can't create new vessels in the right position.
I can create them, give them velocity and rotation, but I have to cheat and use "shiftCG" to get them to spawn in the right place.
It works OK but it's not perfect. Anyone know the proper way to do this?
 
Not sure. I use ms2015 for sls,....you can pm me if you need help
 
Not sure. I use ms2015 for sls,....you can pm me if you need help
He' asking about doing this Lua, not MS2015. This the Lua Scripging subforum after all.
 
- BUMP -

I still haven't figured this out.
Creating the spent vessel is easy enough. Giving it some rotation is fine:
Code:
local vs = vi:get_rawstatus(1)
  local t = vs:get()
  t.vrot = {x=0,y=0.5,z=0}
  vs:set(t)
  oapi.create_vessel("OmegaFairing1", "OmegaFairing1", vs)
I'm giving it a little velocity in the "prestep" of the created vessel:
Code:
if (0+simdt) < 0.01 then
    vi:add_force({x=-600,y=0,z=0}, {x=0,y=0,z=0})
end
But I don't know what method to use to create the vessel in the right position relative to the focus vessel.
I'm using "shiftCG" which is not ideal.
Anyone know the answer?
 
You need to transform the mesh offset from vessel coordinates to planet relative with Local2Rel.
Maybe something like this if you have a mesh_id to spawn from (untested) :
Code:
local ofs = vi:get_meshoffset(mesh_id)
t.rpos = vi:local2rel(ofs)
 
Back
Top