Jump to content

Drawing "Ghosted" parts - Cloning Part Mesh Only (No Physics/Logic)


Recommended Posts

I'm trying to draw a 'ghosted' part in-flight - I don't want the drawn part to interact with physics in any way, nor be selectable etc as a normal part would be.

My first attempt was to simply clone the desired part's GameObject, and disable physics on it as seen below:


clone = (GameObject)GameObject.Instantiate(highlightedPart.gameObject);
clone.rigidbody.isKinematic = false;
clone.rigidbody.detectCollisions = false;
clone.GetComponent<Part>().physicalSignificance = Part.PhysicalSignificance.NONE;
clone.GetComponent<Part>().PhysicsSignificance = 0

The part draws correctly (I'm rescaling it and translating it slightly in a later chunk of code), but unfortunately it still interacts with physics. On top of that, you can select it, right-click it, etc.

So, what I really want to do is to just grab the Mesh component of the part and work with that, throwing out all the logic and physical simulation. But I can't seem to find it! GameObject isn't listing MeshRenderer as one of its components. If anyone has experience with this situation or more familiarity with Unity, I'd greatly appreciate any help.

-NavyFish

Link to comment
Share on other sites

You can get the MeshFilter thusly:


MeshFilter meshFilter = (MeshFilter)clone.GetComponent<MeshFilter>();

AFAIK that is only the mesh, you may also need the MeshRenderer (accessible through gameobject.renderer I think).

Also note that there are typically many transforms with MeshFilters contained within the part hierarchy. You'll probably have to do a bit of iteration.

Of course you could just destroy all the unwanted components from your instance (e.g.: GameObject.Destroy(clone.rigidbody);) it's a bit of a workaround. but at least you wont be keeping unneeded instances around.

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