Use Function in an Attribute
sparkzilla
Member Posts: 152
I have created a set of level attributes in the select level scene
If level = 1
AsteroidPositionX = random(1, 480)
AsteroidPositionY = random(1, 320) <--I want to change these on a level-by-level basis
In the spawner actor in the main level scene I have the following:
Every 5 seconds spawn Asteroid at position AsteroidPositionX, AsteroidPositionY
The problem is that the random numbers are resolved in the level scene and therefore each asteroid generated in the Main scene has the same position.
Every 5 seconds
spawn Asteroid at position 221,123
spawn Asteroid at position 221,123
spawn Asteroid at position 221,123
I would like to know if there is a way to transfer the "random(1, 480)" function text to the attribute without it being resolved (maybe using some kind of quotes or delimiter), which would give
Every 5 seconds
spawn Asteroid at position 221,123
spawn Asteroid at position 132,64
spawn Asteroid at position 12,319
If level = 1
AsteroidPositionX = random(1, 480)
AsteroidPositionY = random(1, 320) <--I want to change these on a level-by-level basis
In the spawner actor in the main level scene I have the following:
Every 5 seconds spawn Asteroid at position AsteroidPositionX, AsteroidPositionY
The problem is that the random numbers are resolved in the level scene and therefore each asteroid generated in the Main scene has the same position.
Every 5 seconds
spawn Asteroid at position 221,123
spawn Asteroid at position 221,123
spawn Asteroid at position 221,123
I would like to know if there is a way to transfer the "random(1, 480)" function text to the attribute without it being resolved (maybe using some kind of quotes or delimiter), which would give
Every 5 seconds
spawn Asteroid at position 221,123
spawn Asteroid at position 132,64
spawn Asteroid at position 12,319
Comments
Then in the random rule instead of having random(1,320) have random(randommin,randommax)
You can then change the randommin and randommax attributes whenever you want in the game, which will inturn change the min and max positions on the random rule
For every 5 seconds
{
// This assigns a random point and saves it in attributes
Change Attribute - AsteroidPositionX = random(1, 480)
Change Attribute - AsteroidPositionY = random(1, 320)
// Then you can spawn an actor from these saved random points
Spawn Actor - AsteroidActor at (X = AsteroidPositionX, Y = AsteroidPositionY)
}
Hope this is what you need. Just put the random changer and the spawner in the same timer rule.