Jump to content

Rotating EVA'd Kerbals


Recommended Posts

Hello,

Simply put, I have a plugin that needs to rotate the active kerbal on EVA, in the way that QE and holding LMB and dragging do. I've tried two methods so far:

1. Using the FlightCtrlState and OnFlyByWire - I have it working for vessels, but it seems that EVA kerbals don't refer to the FlightCtrlState object to get input. Is there something similar to this that can manipulate EVA input? Handing the game proper input would be preferred over the next method.

2. Manually rotating the kerbal's Unity transform object (with vessel.transform.rotation *= Quaternion.AngleAxis(...)). This works, but if the kerbal's jetpack is on, it tries to resist the rotation. Setting the jetpack off (vessel.EVAController.jetpackDeployed = false), then doing the rotation, then setting the jetpack back on, applies the rotation correctly, but when the jetpack comes back on, the kerbal snaps back to its original rotation. Turning the jetpack off with the R key, rotating, then turning it back on, works properly. It seems I need a way to override the kerbals "SAS," or to properly turn off the jetpack in the way that the R key does.

I have referred to the 1.0.5 mod EVA Enhancements which no longer works in 1.1.x in hopes of gleaning something from its code, but I cannot make sense of it at all. If anybody has solutions to either of my two methods, or another way to rotate kerbals, I would much appreciate it. Thanks for reading.

Link to comment
Share on other sites

  • 1 month later...

The Rotation is a bit more tricky:

1. You have to get the private variables from the kerbalEVA structure

2. Set the desired vectors to them.

3. Be happy :-)

 

KerbalEVA eva = shared.Vessel.GetComponent<KerbalEVA>();

FieldInfo eva_tgtFwd = null;
FieldInfo eva_tgtUp = null;

Vector3d lookdirection = (somevector)

var eva_tgtFwd = typeof(KerbalEVA).GetField("tgtFwd", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var eva_tgtUp = typeof(KerbalEVA).GetField("tgtUp", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

this.eva_tgtFwd.SetValue(eva, (Vector3)lookdirection);

 

Link to comment
Share on other sites

  • 1 month later...
On 7/17/2016 at 7:58 PM, WillDaBeast509 said:

Hello,

Simply put, I have a plugin that needs to rotate the active kerbal on EVA, in the way that QE and holding LMB and dragging do. I've tried two methods so far:

1. Using the FlightCtrlState and OnFlyByWire - I have it working for vessels, but it seems that EVA kerbals don't refer to the FlightCtrlState object to get input. Is there something similar to this that can manipulate EVA input? Handing the game proper input would be preferred over the next method.

2. Manually rotating the kerbal's Unity transform object (with vessel.transform.rotation *= Quaternion.AngleAxis(...)). This works, but if the kerbal's jetpack is on, it tries to resist the rotation. Setting the jetpack off (vessel.EVAController.jetpackDeployed = false), then doing the rotation, then setting the jetpack back on, applies the rotation correctly, but when the jetpack comes back on, the kerbal snaps back to its original rotation. Turning the jetpack off with the R key, rotating, then turning it back on, works properly. It seems I need a way to override the kerbals "SAS," or to properly turn off the jetpack in the way that the R key does.

I have referred to the 1.0.5 mod EVA Enhancements which no longer works in 1.1.x in hopes of gleaning something from its code, but I cannot make sense of it at all. If anybody has solutions to either of my two methods, or another way to rotate kerbals, I would much appreciate it. Thanks for reading.

Just an FYI, I have EVA Enhancements updated for 1.2, and will be releasing it in the next few days.  You can see the code on Github when I do release

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...