How do I limit the number of spawned actors to just one?

Tried both of the above but nothing changed, I’ll need to do a deep dive to find out what’s going on.

Create an Actor class that will “Spawn” the campfires. In that class use what @Everynone originally posted.

  • Place the actor in the level.
  • Get a reference to the “Spawner”, then simply Call the Spawn event.

The “Spawner” actor will hold/create the references.

1 Like

You might need to as I feel the issue is elsewhere. If I drop this into a template, in the character blueprint:

Admittedly, there are more graceful ways of handling this, like a dedicated spawn manager actor.

1 Like

Thanks for the reply, I gave that a go however nothing spawns and I get the error message ‘Accessed none’ coming from the call event. When I get back I’ll link a screenshot if you’re interested.

Thanks for the taking the time to do this, really appreciate it.

Looking at the example though it looks as though the player is the actor being destroyed as opposed to campfire itself?

Nah, it’s the campfire, it’s janky because of the collision and movement char comp compensating.

The logic here is:

if old campfire is alive > Destroy it > spawn new one > store reference
else
Spawn new Campfire > store reference

How do we know your Spawn Transform is set to the correct value?

Ah I see, fair enough. When I get back I’ll record a video of the current status, but so far the campfire reliably spawns just in front of the player’s location. When troubleshooting I exited the character and checked the level 0 coordinates just to be sure because when I first implemented the spawn it was arriving there.

So how do you update the Spawn Transform var to spawn another campfire in a new location after the player has moved away?

If in doubt, you can debug it quickly to see where it’s actually spawning:


Is this how it’s supposed to work?

This will spawn it in front of the player.

So I added the logic to the character’s event graph and it works perfectly (so thank you very much, certainly getting there) however when I try to call the custom event in the widget, nothing happens and I get an error message.

“Accessed None trying to read property Master - event graph - spawn camp”

Clearly I’m not calling the custom event correctly, any ideas?

Here’s the new custom event (just a copy of what you did):

And here’s the widget trying to call the custom event:

Your “Master” variable is EMPTY. Thus Access none error.

Verify that your reference is set. Troubleshoot by running Master Is Valid → Spawn Camp. On the Not valid pin do a print string “Not Valid”.

1 Like

Thanks for the reply. Yeah I’m getting the ‘not valid’ response, looks like I need to do some reading up on this.

As above:

You’re most likely referring to this. If the widget is associated with the player in any way, you could use a dispatcher for such action.


I understand the scenario is as follows:

  • we right click
  • a widget pops-up
  • we click-select a campfire from the menu
  • the player executes an event destroying old campfire, and a new one is plopped down
  • and we want to use Switch on Int to filter such action

How close am I?

This is exactly what I’m trying to achieve, yes.

  • the widget calls a dispatcher when the player clicks a button:

  • the player creates a widget and binds the event:


Alternatively, you can cast to the framework class:


Or even create a hard reference in the widget:

And the player sets the value:

That’d prevent Access None errors you’re experiencing. But the first solution is just neater, more convenient, safer.

1 Like

This worked like a charm, thank you SO much for all your help. (I went with the first option as per your recommendation). Thanks to everyone who contributed!

1 Like