Jump to content

Changing Kerbal Z axis relative to planet when "falling in atmosphere"


Recommended Posts

On Eva, when a Kerbal jumps or falls they remain in a standing position, that is, they remain vertical with regard to the planet surface.

I would love to be able to write a plugin that forces them to translate to be perpendicular and facing the planet surface.

I believe kerbalVesselObject.transform.rotation.LookAt would be involved but I don't know how to .LookAt the centroid of the current planetary body.

Is there some flag active when on EVA? (I would need to have it only apply to Kerbals on EVA) how do I get the plugin to only be active in atmosphere?

Link to comment
Share on other sites

A kerbal on EVA is a vessel where Vessel.isEVA is marked true. Once you have that vessel, you can just use Vessel.mainBody.position, and just check if the atmospheric pressure of the vessel is >= 1E-6 to know if you're in the atmosphere. You might want to check Vessel.landedOrSplashed else it'll also apply when on the surface.

Also, I'm no expert in quats, but I think doing LookAt like that would lock the Kerbal in that position. Not sure though.

Link to comment
Share on other sites

https://github.com/Crzyrndm/Pilot-Assistant/blob/master/PilotAssistant/Utility/FlightData.cs#L32

^^ Vector to the planet center from current vessel position (AKA upVector). I would suggest using the surface velocity vector (Vessel.srf_velocity) for this though, it might be a little more natural

If lookAt has a Quaternion input, Quaternion.LookRotation(-upVector) gives you a quaternion pointed towards the planet but doesn't specify the rotation about that vector to use (multiply by Quaternion.Euler(x,y,z) if the orientation is strange, where x/y/z are probably multiples of 90). Use Vessel.transform.forward as the second input to LookRotation if it does wierd rotations (where forward is actually up, because up is forward in KSP...)

You also probably want to use Quaternion.Lerp/Slerp to smoothly adjust from the original rotation

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