Jump to content

Spawning Dummy Parts In Flight Mode


Recommended Posts

As in the title: How would I spawn an empty dummy part in flight mode?

Preferably: No needed .cfg file: Just spawn the part and initialize it on-the-fly.

 

Reason

When I just AddComponent<Part>() I see a stream of NullReferenceException in the log.

I'm assuming there is something wrong with just constructing it as-is, and I'm at a loss as to what else needs to be added to it in order for it to function.

I need to add a part to a vessel in flight in order to force KSP to update the associated transform whenever it changes coordinate frames.

This has been an issue with joints created between dynamically-generated bodies and other parts - when the vessel changes coordinate frames, it causes the joint to correct itself in the wrong frame (the other body, not associated with a part, did not change coordinate frames with the rest of the vessel).

Just adding a part to the related object, then adding the part to the vessel's part list fixes the coordinate frame transition issue, but I see a stream of null reference exceptions.

On the other hand, it would be preferable to hook into an event for this, but I have no idea what that event or override might be.

Edited by coconuts
Link to post
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...