Jump to content

[solved] getPartInfoByName question


Recommended Posts

the task: spawn a part in flight

the problem: the part

let me explain..

if I use the following code on a probecorehex it works..

AvailablePart avPart = PartLoader.getPartInfoByName(partname);

if I use it on my part it does not work.. (I get a null ref on the avPart.prefab value)

the only difference of these parts is one is usable as a root part in editor the other one not.

Can this be the cause of my error?

I've made several parts in the last weeks - some are usable as root others not and I have no clue why..

Can anyone enlighten me where KSP make this difference?

I know I read that about a year ago, but I can't find it anymore and I can't remember either..

My theory: if the above mentioned part would be a "rootable" part, it would work too with my code..

but I don't know what to change..

Details:

My part has a mesh and colliders and I even added a rigidbody for testing - no change..

The part produces no errors in logs on loading, it can be attached in editor without problems and it works in game when loaded with a ship.

Just the getPartInfo won't process it.

Thanks for any hints..

Edited by philotical
Link to comment
Share on other sites

To be a root part it must allow parts to be surface attached to it and attached to a node. I believe these are the third and fourth numbers in the attachRules in the part.cfg. I'm not convinced that it will fix your issue with getPartInfoByName but you can try...

Edited by Padishar
Link to comment
Share on other sites

To be a root part it must allow parts to be surface attached to it and attached to a node. I believe these are the third and fourth numbers in the attachRules in the part.cfg. I'm not convinced that it will fix your issue with getPartInfoByName but you can try...

yeah right - it was the stack and surface needed..

Thanks - I knew it was something minor in the cfg..

And you where also right with the second assumption - this didn't fix my problem..

Does anyone else maybe have some details about why that function could fail on a flawless part?

I'd appreciate any pointer..

The function itselfe (PartLoader.getPartInfoByName(partname) ) does not even throw an error - it works - but if I try to use the prefab-value, then it fails..

so this will throw a null ref exc.

var foo = avPart.prefab;

Link to comment
Share on other sites

that's only true in the editor, in flight there's no mechanical restrictions on which parts can be the root part of the vessel because debris with a single part is a vessel and any part can be isolated.

Link to comment
Share on other sites

  • 3 weeks later...
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...