spawn actor
tarsiustudio
Member Posts: 130
Hello, I want to make an actor who appears in the game at a random time, for it put an actor spawn and put each random (0.7, 2) display the actor, because what it does is that when you start the game creates the actor randomly from these ranges but the actor will always generate the same time. What I do is constantly generating this actor between those intervals but differently each time every second interval to take a different actor each time out differently. I do not know if I explained well and if I will understand because my English is not very good. Javier
Comments
Complete Guide to iOS Publishing {} Complete Guide to Mac Publishing
The problem here is that GameSalad can't change a timer value once the timer has started. So even though it seems to make logical sense to do this:
Timer every [random(0.07,2)] seconds
spawn actor [actor name]
That will just choose a random value once (for example 0.39) and use it over and over. The other issue is that the random() function only accepts integers. So really, it won't even work once. To get a value between 0.07 and 2, you'd need to use the expression random(7,200)/100.
Instead, do this:
Create a real attribute called game.spawnTime.
Add the behavior: Change attribute game.spawnTime (real) to game.Time+random(7,200)/100
Add the rule: When attribute game.Time=game.spawnTime
spawn actor [actor name]
Change attribute game.spawnTime (real) to game.Time+random(7,200)/100
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User