Jump to content

AvailablePart has null rigidbody?


Recommended Posts

private AvailablePart avPart = PartLoader.getPartInfoByName("partname");

This loads the part fine for use, but it's .rigidbody value is null, even after creating a Part object from it. If I try to set it to something, it tells me it's read only.

Has anyone else encountered this? I need to apply a force to the rigidbody and can't because I can't seem to get around this.

Thanks.

Edit: Figured out I needed to do newPart.GameObject.AddComponent<Rigidbody>

Edited by TwistedMexi
Link to comment
Share on other sites

I believe the correct way to do this is to invoke Part.PromoteToPhysicalPart(), else your rigid body will have a bunch of default properties and won't act like the AvailablePart you spawned it from in terms of physics

Edit: At least I'm 100% certain this is the case for parts that don't normally have a rigid body, like cubic struts and other similar pieces that have their transforms attached to a parent instead of a breakable joint

Edited by xEvilReeperx
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...