No need for a collision volume

We don’t actually need a collision volume,
Here’s what I did:

I created a new array of actors variable called Tiles in the game mode.
Inside the SpawnTile method I add the tile that has been spawned to the Tiles array.
I created a function in the game mode called RemoveTile in which i check if the Tiles array’s length is greater than 3
If this condition passes, I get the first element (index 0) of the Tiles array which is obviously an actor, and call the DestroyActor method,
Upon completion of the destroying of the actor I remove the first element (index 0) from the Tiles array

Now on the Tile Blueprint, After calling SpawnTile I immediately call RemoveTile. Now a better name for this method would be something like RemoveTileIfMoreThanThree, but that seems a bit overkill

Now at first I was a bit concerned that the index of the array wouldn’t reset after removing the 0th index, (eg, the first element would be index 1), but this does not seem to be the case

Yes I also wondered about whether collision volumes where the best approach here - it would get messy when modifying to suit a real game scenario, for example where you’d want to support things like having tiles going in different directions.

II’ve made the same process, with seems much more efficient to me than using a destroy volume.
I spawn one tile using the “begin play” event in the InfiniteTerrainGame, than I spawn one tile using the “OncomponentOverlapingEnd” event int Tiles_BP.
And the “spawn tiles” function uses an array to store the spawned tiles and it is responsible of the destruction of the first element of this array when the array lenght is 3 or more

Yeah, I was thinking of something similar. Coding wise it looks like TQueue is the container that suits this approach. @sampattuzzi, might be worth having a gander at this thread.

Also @sampattuzzi if you do decide to redo some of the section to include for C++ I think this would be the best part to do it from. Could also go into solving the potential problem of hitting the end of the world too.

We’ve decided that we won’t be redoing but will be including more C++.

To decide to spawn a new tile, you still need a trigger volume through, right? So we are just removing the volume for destroy. I do like the idea of using a TQueue. The tile and game mode are prime candidates for conversion to C++ in the coming videos.

How I did it: My Testing Grounds work

4 Likes

5 posts were merged into an existing topic: My Testing Grounds work

Privacy & Terms