Why won't my instance get removed?

Trying to spawn hisms procedurally and
remove them if they overlap.

Not sure why but wouldn’t it be easier and more efficient to first check whether there is an obstacle and only spawn where there is none? You’re doing double work atm.

  • place a collision volume at the destination
  • check if something is overlapping
  • no overlaps? → spawn
  • overlaps? → move the collider to a new location
  • rinse and repeat

This way you do need to spawn if there’s no space and there’s no need to remove anything.

1 Like

Trying to spawn hisms procedurally and remove them if they overlap. Problem is they won’t remove at all.

The branch is always spitting out “success” even though I can look and see in my level trees spawning into each other.

Any help appreciated.

I hate to be annoying but would you be able to elaborate on that? So far I’ve been writing this whole function in construction script.

Because I’m wondering if that would that be a new function I write in bps or would that be one of the default events like “On Component Begin Overlap”?

I’m trying to make this run as fast as possible so all my meshes are very simple with just a single capsule collision but for some reason that static mesh collision doesn’t seem to carry over. But they have to have some kind of collisions as my actors do pathfind around it oddly enough.

A collider would be useful if you needed to check for some strange shapes like L-shaped buildings in an RTS game.

If you just need to check if there’s enough empty space, there’s a much simpler way:

Image from Gyazo

… a few moments later …

Image from Gyazo


This sweeps a sphere towards the ground from above, if it hits the floor, that’s good (green) - it means there was nothing in the way and you can spawn your thing. If it hits something else than the floor (red), it does nothing.

I slowed it down to 5/s so we can see it. Pretty sure this can be run faster with instanced static meshes.


Disclaimer: this is not really an algorithm per se. This is just brute force. I’ve been looking at circle packing and sobol sequence recently. There’s some really cool stuff out there. Sobol is in the engine but there’s no documentation for it :expressionless:

I tried to write a new function with what you taught me but the hisms are still spawning into each other. I’m wondering if thats a possible side effect of them not having collisions?

But I really don’t know if they do or not cause they don’t have on one when I turn on show collisions yet ai pathfind around them.

:stuck_out_tongue: this was bp is actually pretty useful.

It does not seem to be set up right at all. And you’re not checking for the correct hits either. Perhaps stick to what I posted for now and get it working and then expand, as you will most likely want to improve it later on anyway since this is rather crude.

From the left:

  • 1000 is how far above the ground we’re shooting from, this value needs to be greater than the highest ground elevation so the beams have room to travel down.
  • (-Z 2000) - this is how far down we’re going, if you have undulating terrain, this value has to reach its deepest crevice. Do note we started from +Z 1000, the beam length is 3000 in total here.
  • and you need to trace vertically down, at the moment you’re just hitting the middle of the world with every beam.

And most importantly

You’re not comparing the results to anything, meaning that things will always spawn - you’re just checking whether there was hit. You need to find out if you’re hitting the ground (good! - spawn) or something else (not so good! - do not spawn).

There are many ways to achieve that, I chose to give the ground mesh a tag and check whether what I hit has a tag.

I’m wondering if thats a possible side
effect of them not having collisions?

You do need collision for this method to work, a simple box will do. You can always switch off collision once they’ve all spawned if it’s not needed during gameplay. Btw, I just tried it with HISMs and it is, indeed, faster than spawning actors! :slight_smile:

Ooh that’s smart I never really knew what the tag function does, my world is boring it’s just completely flat :stuck_out_tongue:

Here’s a picture of what I mean.
If they don’t have a collision how could I add one?

Open the mesh, Add Box Collision from the top.

I don’t follow; the static mesh that is being used as a source for the hism component already has a collision setup. At first a capsule but changing that to box collision doesn’t change anything.

I have use simple as complex enabled if I drag and drop the static mesh into the world I can see the collision but if I spawn the hisms through the bp we’ve created I can’t see any, now their collisions are set to block everything and it does block my camera and pawns, yet the system doesn’t seem to be able to tell when they overlap.

I have use simple as complex

I did not even need to that, everything is at default settings.

Not sure how to help you, perhaps you can post your current setup again and we can try poking holes in it. Here’s what worked for me:

I add a HISM component, and then create instances.

Here’s my setup, your setup worked as well but they were still colliding for some reason I got lower fps off of adding the component then adding the instance not sure why though.

No matter whats plugged into the overlap it doesn’t seem to get detected.

You’re still not tracing right… your End hits 0,0,0. I even highlighted it for you with orange markers. And you added a blocking hit test, which also makes little sense.

Whoops your right never did anything with the end.

Okay I have attempted another way this time using trace for objects.

It’s still not right. Just look at the numbers. Your Origin Z is 0 and you’re adding to the end of ray - you’re firing it upwards from the ground level for as little 0.1 unit.

Also your additional comparisons are unnecessary, although it should work. Not sure why you complicate things, give the ground a tag and forget about it.

Also, you’re tracing for objects now. I do hope you set the collision channels up, otherwise it will most likely not work.

Yeah I switched to for objects because I think it’d work better as I have the hism set to not block visibility, camera or landscape.

I watched a couple tuts and from what I’ve seen if you set it up to use the same number it will make a sphere in a radius around it, but it needs some sort of number so it can still sweep, thus the 0.1 on the z.

I honestly don’t know enough about trace to be able to really even understand what to do with the end otherwise cause my level is 100% flat on the z=0 so it doesn’t even need to be anything…

And so far it does work they just keep colliding I can mess with the end point but I don’t know how that effects it. I did have a get class > = landscape before which worked but they still collide.

Okay so I’ve been watching tuts and reading some documents on it this should work in theory but no matter what combo I try with the red square they still overlap.

If I check the hit actor is landscape, the HISMs, actor tags, component tags, nothing will work. Is this bug report territory or is there some reason the HISMs are still spawning inside each other? The only other way I could thing of is have to variables that are the last HISM’s transform and check that vs the next one’s.

The source mesh definitely has collisions and the HISM collision channels are def setup correctly.(But the collisions on the HISMs still refuse to show.)

Well the main problem is I’m getting confused about what actually goes into the end on that. I’ve watched some trace tuts and if you keep the start and end the same it should trace a sphere around it. But it needs some sort of number to sweep, correct?

Cause if my landscape is 100% flat I don’t need to check the z by 2000? Shouldn’t it just be the x,y?

My objects are set to block everything except the camera, visibility and landscape I have a custom channel called “resources” that the trees are a part of(resource blocks other resource).

And I’m reluctant to use the trace by channel because I need these things to not block camera, visibility or landscape.

Okay Just tried this way.

That’s a default cube mesh I’m using and then I did remove the random rotation/.scale and set the vector to be subtraction.