Jump to content

[Solved] Is there a way to automatically rotate a part when the user attaches it in the editor?


Recommended Posts

Coming at solving the problem with my LES parts from a different way.

Currently, for the part to be lined up correctly with the command pod and also have the lift from the canards be generated the correct direction, the user must rotate the part 90 degrees when they place it in the VAB.

Is there a way that, when they place the part, it is automatically rotated 90 degrees around the Y axis?

 

Edited by Kurld
Link to comment
Share on other sites

Yes there is!

If you want to do this for some reason, you just need to hook up a method to the OnEditorAttach callback:

      private void OnEditorAttach()
        {
            if (_wasAttached == false)
            {
                _wasAttached = true;
                part.transform.Rotate(0, -90, 0);
            }
        }

        private void OnEditorDetach()
        {
            //avoid weirdness with existing craft/parts:
            _wasAttached = true;
        }

 

Edited by Kurld
solved!
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...