Jump to content

transform.position changes after revert flight to launch


Recommended Posts

i've run into a strange thing and i wonder if its a bug

after launching my vessel i check the position of a partmodul

after reverting to launch if i check the position of the same part it changes and after any amount of revert to launch will give the same position

after reverting to VAB and relaunching i get the original position again... actually the one after launching is right but why does it give a different value after reverting to launch?

the code is simply:

Debug.Log(v.vesselName + " - " + localPos + " - " + this.transform.position + " - " + v.findWorldCenterOfMass());

and the output is (right image after launch left image after reverting to launch):

zHTh16F.jpg

Link to comment
Share on other sites

ok, firstof, what i've got is that ksp is shifting the worldcenter to the rootpart after revert to launch but dont do it at launch. i dont know if its intended or bug but a fact. what is strange in this is that

this.vessel.inversetransform[B]point[/B](v.vessel.transform.position)

gives the right local coords after revert to launch but

this.vessel.inversetransform[B]direction[/B](v.vessel.transform.position)

doesnt. it looks like the world turned upside down around the rootpart. nvm, what i want is working with the first one, still its strange

Link to comment
Share on other sites

Okay, I don't have any answers for you, but a couple comments that may help.

First, what I know.

When you goto a vessel on the launchpad by switching the scene so the loading message comes up in the bottom right (Editor -> Flight), the vessel will spawn at world space 0,0,0

I think that anytime you switch to a vessel and incur the Loading message, that vessel will be at 0,0,0 in world space.

Now, based on what you are seeing, when you revert to launch, you don't incur the Loading message, so things stay in the same place, in this case Kerbin does not revert. Rather, time is rewound when you revert, but as Kerbin did not move everything is reverted relative to it.

Note that due to the Kraken and the Krakensbane, World Space co-ordinates are very unreliable. When you switch to a vessel (with the Loading message), that vessel will be at 0,0,0 and will move around as you expect, but only until you hit about 700m/s second relative to world space, at that point the Krakensbane engages and the vessel stops moving in world space and everything starts moving around the vessel.

It has to do with the fact that Unity only uses floats with 7 significant figures for location numbers. With the scale KSP works at that is simply not big enough and so Squad implements these workarounds.

I have not done anything extensive with world space coordinates myself so that is about all I know, but the big thing is that world space coordinates are relative and unreliable, if you are going to use them you need to refresh them often.

On the inversetransformpoint and inverseinversetransformdirection, you are getting two concepts mixed up. Vector3's can be either a location point, or a direction of movement, there are two very different things even though they look exactly the same.

If you have a PointA, PointB and TravelAB vectors, use inversetransformpoint to convert PointA and PointB location vectors from World Space to Local Space and use inversetransformdirection to convert TravelAB from World Space to Local Space.

D.

Edited by Diazo
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...