# Random Spawn Unit Trigger

Status
Not open for further replies.

#### gritpatrick

Level 5
So I have already made a random unit group with units I want to spawn. It works but the issue is that when I do

Unit - Create 2 WaveSpawns[(Random integer number between 1 and Random_Count)] for Player 12 (Brown) at Temp_Point facing (Position of (Triggering unit))

it selects 2 units randomly and summons them twice. So for example, if it picks a footman it will spawn 2 of them. So if I were to say spawn 8 units I would get 8 footmen if selected in the random group.

What I want to do is use Unit Create to create 2 random units literally, so 1 footman 1 grunt on to a position
So if I did create 8 units it would create 8 random ones. Right now I have to do this 3 times

Unit - Create 2 WaveSpawns[(Random integer number between 1 and Random_Count)] for Player 12 (Brown) at Temp_Point facing (Position of (Triggering unit))

Unit - Create 2 WaveSpawns[(Random integer number between 1 and Random_Count)] for Player 12 (Brown) at Temp_Point facing (Position of (Triggering unit))

Unit - Create 2 WaveSpawns[(Random integer number between 1 and Random_Count)] for Player 12 (Brown) at Temp_Point facing (Position of (Triggering unit))

Just to have random units spawn, I just want to know if there is a more effective way of doing it without having to do that 3 times.

#### Dr Super Good

Spell Reviewer
Level 64
So if I did create 8 units it would create 8 random ones. Right now I have to do this 3 times
That is 3 random unit pairs or 6 units in total. 3 x 2 = 6. You would need to repeat the action 4 times for 8 random unit pairs or 8 times for 8 random units.
Just to have random units spawn, I just want to know if there is a more effective way of doing it without having to do that 3 times.
Use a for integer loop to repeat a single copy of the action 8 times. That is what loops are for.

#### gritpatrick

Level 5
That is 3 random unit pairs or 6 units in total. 3 x 2 = 6. You would need to repeat the action 4 times for 8 random unit pairs or 8 times for 8 random units.

Use a for integer loop to repeat a single copy of the action 8 times. That is what loops are for.

OOF how did i forget that trigger existed thanks.

#### gritpatrick

Level 5
Hey I got a quick question, So this is my random group list. Every time the game makes a unit from the group it lags. Any way to reduce that lag?

#### Attachments

75.9 KB · Views: 28

#### Dr Super Good

Spell Reviewer
Level 64
Any way to reduce that lag?
Pre place 1 of every unit on the map in the World Editor. On map initialization remove all the pre-placed units. This moves the lag to the loading screen.

#### Ceday

Level 12
Hey I got a quick question, So this is my random group list. Every time the game makes a unit from the group it lags. Any way to reduce that lag?

View attachment 347221
By the way, index 27 is missing in your list (not sure if this is intended or not).

#### gritpatrick

Level 5
Pre place 1 of every unit on the map in the World Editor. On map initialization remove all the pre-placed units. This moves the lag to the loading screen.

hmm, so after i do that everytime the game spawns a unit from that unit group it wont lag? how does that work curious to no

#### gritpatrick

Level 5
By the way, index 27 is missing in your list (not sure if this is intended or not).
lol thanks for pointing that out

#### Dr Super Good

Spell Reviewer
Level 64
hmm, so after i do that everytime the game spawns a unit from that unit group it wont lag? how does that work curious to no
It pre-loads all the units. The "lag" is likely the result of an asset stall as the unit models and ability data get loaded.

Status
Not open for further replies.

Replies
36
Views
2K
Replies
2
Views
622
Replies
13
Views
3K
Replies
5
Views
749
Replies
4
Views
332