Jump to content

How to save vessel position, and then teleport back to that position?


Recommended Posts

I'm working an old mod, AirPart.  Turns out the mod works, but has had a bug when changing scenes.

Parking a vessel at altitude, jumping to the Space Center scene and then returning will return the vessel to the same location, but at 0 altitude

So, digging into the code, I find that it does this to get the  current vessel position:

...
ParkPosition = GetVesselPosition()
...

// Following code from Hyperedit

        private Vector3d GetVesselPosition()
        {
            var pqs = vessel.mainBody.pqsController;
            if (pqs == null)
            {
                Destroy(this);
                return zeroVector;
            }

            alt = pqs.GetSurfaceHeight(vessel.mainBody.GetRelSurfaceNVector(Latitude, Longitude)) - vessel.mainBody.Radius;
            alt = Math.Max(alt, 0); // Underwater!

            teleportPosition = vessel.mainBody.GetRelSurfacePosition(Latitude, Longitude, alt + Altitude);

            return teleportPosition;
        }

So, in Start, I have the following:

                if (Parked)
                {
                    vessel.SetPosition(ParkPosition);
                }

and it doesn't do anything.

I tried as a test putting this into FixedUpdate():

                if (Parked)
                {
                    vessel.SetPosition(ParkPosition);
                }

and it ended up 1000km high.

I'm pretty sure this is something to do with the multiple points of origin, but no idea where to go.  Would appreciate a pointer or two, thanks

 

Happy  New Year

 

LGG

Edited by linuxgurugamer
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...