SpawnActor output when not spawning

Currently I’ve got some simple blueprint-code that spawns the actor ‘Ball’. I then print the output of SpawnActor to see the name of the spawned actor which is -logically- ‘Ball_C_1’, ‘Ball_C_2’, etc.

Now here’s my issue. The SpawnActor has a ‘Collision Handling Override’. I’ve set it to “Do Not Spawn”, so when there’s something blocking the spawnpoint it will not spawn. Great, there’s no ball actor spawning now, however, SpawnActor DOES return the value ‘Ball_c_x’ (where x is number of balls spawned).

So what happens now is, when pressing the spawn button for example 20 times very fast, it will spawn ‘Ball_c_1’ and then count all the way to ‘Ball_c_20’. So now, when the spawnpoint is clear again, the next actual spawned ball will be called ‘Ball_c_21’.

My issue here is, why does SpawnActor return a value when it’s actually not spawning anything. Why does it not return something like a null? Is there a way I can catch this?

Because it WAS spawned, there was just no space for it.

I somehow missed the notification of your response.

Okay so, it was spawned, but I assume somewhere underwater there must’ve been an error/warning that there was no space to place the item.

In any case, how can I avoid spawning when there’s not space for it? Should I create some kind of collisionbox that serves as an area that if there’s collision I should not be able to spawn anything? Or is there a better solution?

Yes, you have to figure out where is a good place to spawn. You can always spawn, of course, but it’s really up to you to handle the consequences.

1 Like