How to the actor spawns in one the designated area?

Hello friends.

I have a question like in title. I have an actor. This actor is present in different numbers on each map. I want these actors to occur randomly in one of the places I have determined on the map. For example, I have 2 actors in the 1st map and there are 6 areas that I have determined. These 2 actors will be randomly formed in one of the 6 areas and they will not be able to occur simultaneously in the same area. So a field can only host one actor. how can I do that? I hope there is an instructional video about it. Thank you and have a nice day.

Make an actor blueprint, call it TargetLocation. In contains no code, just a variable

image

Put some of these blueprints in your level and set the spawn radius ( you can make the default 250, for instance ).

Make an actor blueprint, call it PlaceActors. It has the variables:

image

Locations = An array of TargetLocation blueprints ( from above ), just declare it, nothing to set.

ActorsToSpawn = The number you want to spawn

Mesh to spawn = The mesh you want to spawn ( we can change this if you want to spawn a blueprint ).

The code is like this:

Place it in the level, and set the mesh and number you want to spawn

image

Press play :slight_smile:

2 Likes

can i call you King? :slight_smile: :slight_smile: :slight_smile:

1 Like

:innocent:

1 Like

Oh one more question I have, so how can I get it detected if the character hits any of these? :slight_smile: I hope you know about this. This is how I normally use it. so when the character hits this actor, the actor destroy.

If the character hits the spawned things?

Best way would be to place blueprints instead of static meshes.

The procedure is exactly the same, but instead of spawning a mesh and setting it, you spawn a blueprint of your choice :slight_smile:

1 Like

I will try, I hope I can do it. it looks a bit confusing because i’m very new to game making ^^

Just change this bit

image

to the name of your blueprint, and get rid of this bit:

image

1 Like

OMG! YOU are really perfect! now it worked exactly as i wanted :slight_smile: :slight_smile: :partying_face:

1 Like