Ue4 building system: how to remove duplicate box collisions

There’s a lot of things to consider there. The first question that comes to my mind is, are you going to be able to remove the geometry/actors after they’ve been placed? If so, you might not want to remove the collision boxes at all. Replacing the collision box could end up being more difficult than working around the duplicates. Not saying it would be, just something to consider.

To more directly answer your question, you could just use overlapping events to get an array of references to the box components that are overlapping and destroy/hide them that way. You could probably just pick one out of the array at random if it makes no difference.

I’ve recently implemented a building system that uses box collisions as Possible build locations. When I spawn the Build actor and tile them or put them together the box collisions are inside one another so there are duplicates. How would I remove these on spawn? Thanks.

Thanks for replying. When the build is placed I disable the collision box and is its connected to another build I parent it to the original build. I’m most likely going to add a destruction system and remove the static mesh from the actor. But how would I only remove 1 of them. Whenever I use the overlap event it either removes the collision boxes from the itself, or it removes both of the boxes. I only need 1. It may be something simple but I can’t think of it rn.

It’s possible to do it with overlapping events, but I just thought of a cleaner method. You could maybe setup your build actor to throw out traces on a custom channel for collision boxes when placed. You could then use these hit results to remove the collision boxes of the actor you just placed. For example, if you place the build actor and then get a hit from a trace that is going upwards, you can then run an event or function that destroys/disables the top collision box component of the newly placed actor.

I’ve been trying out a box trace for collision box and it works! BUT for some reason I can’t disable it nor destroy it. The trace is hitting the component. But how would I solve this with floors? (Placing the build actor next to each other) then the floor collisions would be overlapping with the other actor.

My suggestion was to disable it on the actor that is doing the tracing, that way you don’t need to pass a reference. Why can’t you do a trace for the floors? Just trace out sideways.

I don’t think you under stand what I’m going for. Imagine this: I have an actor, Lets call this actor 1, Then I place a floor next to actor 1, lets call this actor 2. When I’m looking at actor 1 I want to disable the collision in actor 1 and delete the collision in actor 2 if its a duplicate. Or if there is a way I could destroy the duplicate component on spawn/beginplay.

My problem is I can’t destroy the component from the actor that is doing the tracing. I may be wrong but I think it’s because the actor that was calling destroy component wasn’t the owner, as the description of the node says. How would I destroy it?

The parent actor of the component should be the owner, and should be where the tracing logic is. Simply drag a reference of the box onto the graph and plug it into the destroy component node. I just tried it, it definitely works. You might have something else going on in your hierarchy or logic. Another alternative is to just change the collision on the box instead of destroying it.

Yes, you can do it on spawn/beginplay. Just run the trace on actor 2 spawn/beginplay and have it run a function/event that destroys the component in actor 2 when it hits something on a specific collision channel from actor 1.

On the trace hit, you can also grab a reference of actor 1 so that actor 2 can call an event/function from inside actor 1 to disable it’s collision. You could also disable actor 1’s collision directly from inside actor 2, but I think it’s cleaner to have actor 2 call an event/function that resides in actor 1 instead.

Here is how I’m currently doing it, it may be a little or completely different than what ur suggesting but I got it to work sometimes. It sometimes deletes the right component and sometimes doesn’t. I’m posting this because I’ll try this again tomorrow. If you spot anything wrong please do tell. I am indeed new to building systems. Thanks for helping me out this far.

No problem, I built something similar a few years ago. This can, and probably will, get very complicated, very quickly.

The logic you posted would be the equivalent of destroying the component in actor 1 from the trace in actor 2. You may be able to do it this way but it’s much more complicated. It would be much easier to destroy the component that is in the same actor as the trace. You can find out which component to destroy just by knowing which traces get a hit.

I would also recommend doing a trace by channel (not object) and setting up a custom trace channel. That way you have a lot more control over what does and doesn’t return a hit from a trace.

How would I rotate the trace? I got it to work with walls but not floors.

I’m not sure I understand the question. My suggestion involved separate traces in each direction.

I know I realized after I posted it, I could probably just use the x or y axis as the trace start and end.