Is it possible to overlap spawned box collisions?

I’m trying to create an endless runner like world generation but in 4 directions. I watched some tutorials but only one direction has worked every time.

I tried my own solution which is basically just spawning on a sphere when the character overlaps a box collision. This is working but the collision is not resetting, I cannot overlap the newly spawned one. I made a boolean which is true when overlapping and false when the overlap is ending. This is happening in the actor’s BP and the spawning in the lever BP.

1 Like

All 4 directions should work, but a couple of things

  1. Do it all in the blueprint

  2. You have the problem, that when you spawn the new BP and step across into it, it will spawn on where you have just come from, so you have to deal with that :slight_smile:

I tried doing it in the actor’s BP, and I got an infinite loop. I read that I cannot really spawn it from itself.

Also, I thought about it spawing to the same place but that is not true. Since I have 2 directions, If I go right and the new spawns, then if I go forward on the new one, another should spawn in front of the original where I started but nothing is happening. I checked it in the BP’s debug mode and the execution pins are not doing anyting with the spawned collision.

That’s what I’m saying, you will get a loop, unless you deal with it.

As you cross the box, the BP will spawn another BP, but that will overlap with you and try to spawn one where you already are. Etc…

You have to write the BP so it won’t spawn if there is something already there. Then you won’t get the loop.

It’s up to you how you do that. You might do a line trace to see if one is already there, for instance.

I tried to make a do once and even turning off the collision as soon as the spawn happens but none of it made the spawning once.

1 Like

I’m doing an example…

2 Likes

So, similar BP

The code is

and the function is

GetAllActors is fine if you only have a small number ( < 10 ) in the level. So you’ll need to destroy them when the player some distance away.

tiles

1 Like

Oh my god… Thank you! I will try this out today and give you a feedback if I could managed to do it!

1 Like

No worries :slight_smile:

The bit of vector math ( btw ) is just so we can spawn the next BP on the correct axis, without having to figure out which box we collided with and all that…

1 Like

I got a few questions during I tried to copy it:
1, How do you get all of the boxes in an array? I mean I can create the variable but I guess it will not reference the 4 boxes.

2, How did you get the SET target location node? I only has one with the target

3, What to do with “tile size” and “target location” variables? Do I just have to create or do I need to set something particular in those?

1 Like

You could probably get the tile size from the static meshes bounds => box extent.

If the spawned tile wasn’t square then you would need to pass in a different offset value depending on the spawn side.

1 Like

Just drag the references into the graph, then drag a pin from one and type ‘make array’.

I have a vector variable called ‘target location’. Just drag it into the graph and choose ‘set’

set

Tile size needs to be about 300 or so, depending on the size of your tile.

It seems working wonderfully! Thank you!

The only thing is, if I’m walking in a collision, and going over another one, it is not registering the other and not generates a new tile.
I tried to enlarge or make smaller the boxes, make these collide with each other, separate from each other but couldn’t find the perfect way

1 Like

No, that won’t work. If you are walking along inside one box, and overlap with another box on the same bp, it won’t register.

If you want that to work, then you have to check for overlap on each of the boxes separately.

It is just an example :slight_smile:

1 Like

Soo, if I’m not making an array for the boxes, but doing something similar for each one, it could work? Or somehow is it possible that after making a new tile, that specific box’s collision get disabled?

1 Like

No, it’s because we’re using

image

it treats all the boxes as one thing.

If you want to add more complexity, then you need to

image

for all 4 boxes.

Then you don’t really need the vector stuff, because you know which box you just hit and so what direction we are talking about.

1 Like

Ah, okay. Then it seems I got the good idea at the start when I wanted to do it just couldn’t do anything after that :smiley: That’s where I got the infinite loop
I think I will use your solution, because that is working, not like mine

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.