Spawn randomly inside actor blueprint

Where do you have that array for target points? What are they? Just an array you populated manually or you fetch the data somehow?

You can absolutely do all of what you said are more! I’ll post some examples later, potentially tomorrow unless someone else chips in before that. Stay tuned.

I currently have a health pickup that spawns at a specific point but I want it to be a random location based on an array of target points. The issue is that the only way I know how to do that is to set that up in the level blueprint. I can’t seem to get my level blueprints to get reference the health of character. Is there a way to setup a random array inside the character blueprint instead of the level blueprint? It would be easier to access my character’s health variables.

I had them in the level by just dragging them into the scene and placing them wherever, which is why I thought I needed to do it inside the level blueprint. I was doing by just piping in the target points into the array with a random integer node, but that method is not referencing the player health the way I need to. But I would rather add them into the actor blueprint, similar the way I would to a component. That way the random spawn points would still sort of attached relatively to wherever the player is. I thought it would be cool to parent them under the player scene component. I don’t think I can add target points into an actor blueprint, I didn’t see the option for it.

That would be great. Thank you!

It would be easier to access my
character’s health variables.

Is there a reason why you need to do this? Is there some special mechanics you’re after? Could you describe why another blueprint needs to know about player’s health value?

I’m going to post several examples, each slightly different. Do tell what you think and if anything caters to your needs and / or needs changing in the way it works:


Using tags and placing spawn points manually:

  • a SpawnPoint actor with an arrow so we can see it
  • and a tag so we can identify it

  • these are manually dragged & dropped into the level

  • at Being Play, the player grabs the references of all potential Spawns Points
  • we then store the reference in an array and Shuffle it
  • getting 0 element from that array will result in a random actor
  • a pickup is spawned at that Spawn Point location

That way the random spawn points would
still sort of attached relatively to
wherever the player is.

This one is a bit strange but why not:

Image from Gyazo

Now you have a bunch of spawn points that move with the player.

I tried the first method below. I added it to my character blueprint, and it does spawn randomly, but I need it to do so only after the player health falls below a specific amount. I tried this but I can’t get it to work when I hook up the health condition to it.

I currently have a health pickup that
spawns at a specific point but I want
it to be a random location based on an
array of target points.

Let’s try literally this (even though I omitted the other bits you mentioned that are important)

  • this populates an array with a bunch of points:

  • when we’re ready to spawn something, we adjust the location by player’s location

This way those points always travel with you and whenever something needs spawning, a random point is chosen from the yellow points.

Oh I just figured it out. Instead of on Event Begin Play, I created a custom event, and then I called that event after the health drops. works perfectly now. Thank you for the setup. I like using the “tag”, I’m going to use it more often!

This one is really cool too. I’m also going to try this one on my next pickup

It does not work because you’re doing it on Begin Play - I’m just following what you’ve requested - picking a spawning point at random. You’d need to call it properly in game (what’s called Respawn in my images) when player’s health drops.

I sense there are details you’ve omitted in your description and what I’ve posted below is useless. Consider describing how the feature works. Don’t worry about technicalities. As in:

  • when the player health drops below certain value a (health?) pickup spawns nearby

How close am I?