Help with building system

Hey all I have a simple building system where the player can select a building from a list it will follow the cursor and the player can drop it into the world. My problem is that I use a multisphere trace to detect if there are any hisms in the way of where the player wants to place the building.

But it doesn’t always detect what is overlapping and what isn’t, I’d say about 50% of the time it will pick up the hism that is overlapping, which is not good. The goal is to get every instance overlapping add it to an array that way the player cannot build the building until every blocking mesh is removed.

  1. The player clicks button and the ghost mesh is spawned and follows the mouse.

  2. The player clicks somewhere they’d like the building to be.

  3. Every overlapping hism is added to an array and the ghost mesh is placed in it’s spot.

But no matter what it doesn’t seem to pick on every mesh sometimes it does and it works fine but then other times it just straight up ignores it and marks the spot as clear. I can see that the multisphere trace is indeed covering the hism so it should be getting detected, it just isn’t.

You can create your own object types and trace only against those - this is great from the performance point of view, especially if you trace a lot and other things are in the way. You wouldn’t even need to cast or use tags.

And general info on collision filtering in case things do not add up:


I actually wouldn’t use a sphere trace for this. Wouldn’t a box be more logical (unless your building are spheres, too, of course)?

To be honest I’d just plop down a box collision volume and get all the stuff it overlaps. You already have building ghost mesh - why not just get everything it overlaps instead. Maybe there’s no need for all that tracing. Maybe I’m misunderstand what you’re trying to do, though.

Just realised you’re dealing with (H)ISM - this is more complicated than you think then - look at those 2 nodes if you want to start overlapping (H)ISMs:

  • Get Instances Overlapping Sphere
  • Get Instances Overlapping Box

Otherwise you’re getting only the original component rather than its instances. If you all you want is a True/False something is/not overlapping, that’s fine. If you want the actual number of instances in the way, you need to use the above nodes.

Image from Gyazo


On the other hand, unless you have something specific in mind, the multibox seems to work surprisingly well once combined with object channel:

Image from Gyazo

Perhaps the way you trace or the tags are incorrect - I do not know how tags instancing works with (H)ISM to be honest. If you set up an object channel, you neither need to cast (which is expensive every frame) or use tags.

but the trace always returns “x”
amount of tiles on an overlap.

Perhaps there’s something not right with the tags. Not sure if you can get it to work like that; do tags work with HISMs? Try testing it be getting a tag out of that cast and print it.


I used object channels in the above example and it cleanly picks up only correct objects - a super clean and efficient solution that allows you to filter out any undesired elements. You’re actually already using it, kind of - the Trace Objects array. It’s a matter of creating and assigning your obstacles ("[…]trees, bushes, grass or rocks") an object type.

One note here: the loop terminates immediately after the first iteration as you’re not using the Completed pin. Not sure if that matters here but it will produce inconsistent results under certain circumstances.

You’re hitting the floor tile, it is a HISM and the loop returns no overlaps - this is most likely an issue here. Perhaps only return values once you’ve gone through all elements the multitrace returned.

Hmm well I’m trying to use the trace as I need to pick up on any potential overlaps. So any world objects like trees, bushes, grass or rocks or whatever are using hisms. But then their are actors that can also potentially be in the way so I’m trying to trace against everything.

Any hisms are traced first, if tag matches “x” then it’s overlapping. And then for actors. The problem is the ground is made up of large hism tiles so the player can edit the world in runtime, but the trace always returns “x” amount of tiles on an overlap.

On the get instances overlap box it would work but is there some sort of way to have it ignore my ground? It seems to only return an int of “x” amount of hism overlaps not the actual instance info though…

Yeah the hisms tags do work properly I use them for similar traces for other parts of my project. I do have object types assigned, but if I tell it to not pick up on the type the ground is set to it still seems to pick it up anyways but it always returns an overlap, even if the “overlap” is the ground and nothing more.

My overlap detection is firing off the tick as the ghost is following the mouse cursor to see where the player wants to place the building. So I didn’t even bother with the completed, would that be a better way of doing it?

Would that even work off the completed though? It needs to be able to pick up on every overlap every tick and it could potentially be multiple in the sphere, I could just be confused.

I have the floors set to a world static, if I remove that from the trace objects array it will work correctly one time, if it overlaps with anything at all the ghost is permanently stuck to unplaceable. I don’t understand why though as it’s running on a tick so it should be constantly updating.

So it’s detecting the hisms even though their trace channel is set to not be detected, so it will just always return an overlap. If I tell it to ignore the hisms with the “ground” tag it just counts everything as not overlapping so I can just place buildings inside each other and ontop of trees and ■■■■.

This one works the best I’ve found but still has trouble if the mesh is big.

And this is the one with the weird bugs

I do have object types assigned, but
if I tell it to not pick up on the
type the ground is set to it still
seems to pick it up anyways

This does not seem right judging by the setup in the pic. If the object types were set up correctly, you wouldn’t be picking up ground tiles. Your Object Traces array contains object type of the floor, surely.

Would that even work off the completed
though? It needs to be able to pick up
on every overlap every tick and it
could potentially be multiple in the
sphere, I could just be confused.

No, it hits the first thing and exits, it does not even try to look for anything else or care about the tags. For example, you hit the floor, the tags do not match obviously, so we’re not overlapping → terminate loop and say - hey, we’re not overlapping anything.

Which is often not true as there might be other things nearby, things we never checked against - other elements returned my multi trace.

So it’s detecting the hisms even
though their trace channel is set to
not be detected

Are you saying the floor HISM Object Type is set to World Static and that trace still detects it, event though it’s not in the object type make array?

In this case it is a bug I cannot reproduce it on my end, sadly. Just tested this.


Apart from the above possibility I do not see a bug here.

You force the loop to exit on first hit no matter what, whether it hits the floor or not. It never really has a chance to check for anything else :expressionless: Now with cast failed handled, you will terminate if you encounter anything on the make array list.

What’s worse, by not using the Completed pin, you risk running into an undetermined situation where you return the default boolean value. Luckily this never happens because the loop exits prematurely every time. This may be something that you do want, though.

If you believe it’s solved, convert your own comment into an answer and accept it. Not sure which of my comments qualifies.

Glad to hear you got it to work somehow.

I figured out part of the problem, the world is made out of large tiles like in civ or something so those are also hisms and the trace is hitting them as well causing incorrect overlaps to occur.

I figured I could just trace against component tag(ground) because if the overlapping component has that tag it means its on level ground and if it doesn’t have that tag it means its overlapping the mesh. It only works one time though like the bool is getting stuck to false for some reason.

Okay I think with your help I’ve gotten it figured out! Thanks!

Now taking it way back, I was originally trying to do I trace with the box but I couldn’t figure out how to get the proper numbers for the trace from the ghost mesh component.

Ps having trouble marking your comment as an answer for some reason the marker isn’t there?

Yeah I believe your correct, it was an error as a result of me not using the completed pin. Thanks!