- Home /
Is there any way I can delete the part of a GameObject that is inside another?
So I have 2 GameObject being placed by the player. Sometimes they intersect. I need to delete the area that is being intersected. Here is an example of what I'm talking about:
Why? Is this just for visual effect? How do you deter$$anonymous$$e which piece gets a part removed? Do the pieces get moved apart again? (And, if so, do they become whole again?)
It's because sometimes when the player places the object, they're stuck inside of each other, then they kinda "pop" back outside of eachother. However, I want them to be able to intersect the parts without them popping back out. I know exactly which part I want removed, and it doesn't need to be whole again when they are moved apart. The pieces do need to be able to come back apart, though.
Possible, but verydifficult, and even more difficult for non-box shaped colliders. Involves a lot of complicated math, uv recalculating, vertex operations, and per-face slicing plane deter$$anonymous$$ation.
What would happen to the outer faces that are removed? The mesh would have gaping holes in those places.
I would suggest rather than destroying or changing the shape of the game object you simply turn off it's collision physics. This will prevent collisions which should prevent your player from getting stuck in the object. There are a couple of ways to do this, I like the method suggested in this post, which basically says, to change the objects collider component into a "trigger collider" (no physics, calls a function ions$$anonymous$$d), for the duration you need, then change it back. http://answers.unity3d.com/questions/10883/how-do-i-disable-collision-for-an-object.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613180644im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is there a way to dynamically populate game objects via texture maps? 2 Answers
How to assign a gameobject to a script that is added dynamically 1 Answer
Instantiate flexible amount of objects to prevent frame rate drop 0 Answers
Switch to New Shader and Back to Original object's Shader in C# Script 0 Answers
Find a variable using a string 1 Answer