Jump to content

Spawning a model (part) from an modified existing part?


Recommended Posts

I have a part that has a force applied to it, to fly off in a random direction. What I need help with, is how do I spawn that part mid-flight, when an existing part has been triggered?

I've modified the inline clampotron part as my base model, and ideally when the bay opens, (toggle event) I want to hook into that and then spawn this part, detached from the main vessel, or in a state where I can then tell it to detach. Is there a way to do this?

Thanks for any help.

Edit: I've figured out how to use instantiate to spawn it, but I keep getting null reference when accessing .rigidbody of my new part.

Edited by TwistedMexi
Link to comment
Share on other sites

Well, the easy way would be to unload the vessel manipulate its protovessel and re-load it. That shouldn't be very hard since protovessel is mostly similar to the saved text file format and you can compare your vessel with and without the spawning part. Ofc you can also try to only do the necessary loading for a single part, but that means you would have to figure out a lot of stuff by yourself if there isn't any other mod doing sth similar you can learn from. KAS might be worth a look. Its the only mod i use that adds parts to a ship.

Link to comment
Share on other sites

So there's no way to simply call a spawn part(vector), vector being coordinates? It seems to me you shouldn't need to unload the vessel to do this.

It's going to be spawning several of these, so unloading and reloading the vessel seems expensive.

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