Jump to content

How to move gizmo when moving a part


Recommended Posts

I'm now successfully moving a part in the editor using keys instead of the gizmo arrows.

It seems that the gizmo position isn't being updated, so when you grab the part with the arrow, it jumps back to where the gizmo thinks it is.

I'm looking at the visible and hidden members of the GizmoOffset and GizmoOffsetHandle classes, but nothing seems obvious, except that there are a few functions which are totally hidden.  Maybe I'm looking in the wrong place, anyone have any ideas what to change?

Thanks

Link to comment
Share on other sites

Unfortunately, the EditorLogic, GizmoXXX and GizmoXXXHandle classes are intricately interlinked, lots of the code concerned is private, and there is no remotely easy way to do what you want.  I also want something similar as I would like to make Part Angle Display enable the rotation keys in rotate mode.  There were some potential changes on the table for 1.1 that would have made this easy so I never fully investigated whether it was actually possible to do it now via reflection or some other underhanded method.  However, those changes to KSP had to be postponed due to more serious issues that needed to be worked on.

Link to comment
Share on other sites

1 hour ago, Padishar said:

Unfortunately, the EditorLogic, GizmoXXX and GizmoXXXHandle classes are intricately interlinked, lots of the code concerned is private, and there is no remotely easy way to do what you want.  I also want something similar as I would like to make Part Angle Display enable the rotation keys in rotate mode.  There were some potential changes on the table for 1.1 that would have made this easy so I never fully investigated whether it was actually possible to do it now via reflection or some other underhanded method.  However, those changes to KSP had to be postponed due to more serious issues that needed to be worked on.

That's sad.

I wonder if I could force it by disabling and then reenabling the gizmo.  I saw that if I had moved the part with my own code while the offset gizmo was active, and then disabled and reenabled the gizmo, the position stayed, it only gets reset if the part is moved and then the gizmo is used.

Link to comment
Share on other sites

Yes, that is one of the possibilities that I didn't bother to investigate (yet)...

Another is, for rotation anyway, that there is an event that can be fired when a part is rotated but I don't know if the GizmoXXXHandles will respond to it correctly.  There may be a similar event for translation.

Link to comment
Share on other sites

Just now, Padishar said:

Yes, that is one of the possibilities that I didn't bother to investigate (yet)...

Another is, for rotation anyway, that there is an event that can be fired when a part is rotated but I don't know if the GizmoXXXHandles will respond to it correctly.  There may be a similar event for translation.

What is that event, cause I was going to be working on rotation using keys next and would like to see if it works.

Also, would you know how to disable and enable a gizmo from code?

Link to comment
Share on other sites

On 5/11/2016 at 1:02 PM, Padishar said:

I don't have access to much stuff at the moment but I think this is probably the one...

GameEvents.onEditorPartEvent.Fire(ConstructionEventType.PartRotated, part);

@Padishar

I've figured out how to move the gizmos.  Once I get it finished, you can look at my code to see how it's done.

Will be a couple of days, maybe, as I'm busy with RL

LGG

Link to comment
Share on other sites

2 hours ago, linuxgurugamer said:

@Padishar

I've figured out how to move the gizmos.  Once I get it finished, you can look at my code to see how it's done.

Will be a couple of days, maybe, as I'm busy with RL

LGG

@Padishar

I just released it, you can get the source from github

It uses Reflection, you MUST use the offsets as I did so that you maintain compatibility with Linux and OSX.  I got scolded because I was using names.

Keep in mind that once you do this, your then has the possibility to not work on different releases.  I've added code to EEX so that it just won't run on newer versions of KSP, this was done so that I wouldn't get flooded with bug reports every time a new version of KSP is released.

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