Spawning random actors
umei
Member, PRO Posts: 21
I am looking to spawn random obstacles in my game. My obstacles are spawned every 2 seconds so I made an attribute 'random obstacle' and changed attribute to random(1,3) in a timer.
Here is how my controller actor is set up:
http://imgur.com/hXr2FKg
Then in my goal actor I am have 3 rules for each obstacle like below:
http://imgur.com/Nu0qsBQ
The random obstacles spawn correctly but they spawn on top of each other. I can not figure out what I am doing wrong.
Here is how my controller actor is set up:
http://imgur.com/hXr2FKg
Then in my goal actor I am have 3 rules for each obstacle like below:
http://imgur.com/Nu0qsBQ
The random obstacles spawn correctly but they spawn on top of each other. I can not figure out what I am doing wrong.
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Log(Actor: goal ): 229
Log(Actor: goal ): 229
Log(Actor: goal ): 94
Log(Actor: goal ): 94
Log(Actor: goal ): 94
Log(Actor: goal ): 228
Log(Actor: goal ): 228
Log(Actor: goal ): 228
Log(Actor: goal ): 128
Log(Actor: goal ): 128
Log(Actor: goal ): 128
Log(Actor: goal ): 183
Log(Actor: goal ): 183
Log(Actor: goal ): 183
Log(Actor: goal ): 249
Log(Actor: goal ): 249
Log(Actor: goal ): 249
Log(Actor: goal ): 118
Log(Actor: goal ): 118
Log(Actor: goal ): 118
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Also, one thing to note is that if you have an integer attribute and you set it to a value such as random(1,3) and then you have a rule when game.random=1... you don't need to also include conditions for when game.random≠2, game.random≠3, etc. By definition, the condition game.random=1 means that game.random doesn't equal any other values.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
To give you an analogy, let's say I said, "Run to the end of the field and drop a cone every time I say 'now!'" You'd start running and when I said 'now,' you'd drop a cone. Now imagine there are twenty people standing next to me and every two seconds I point to one of them and say "Run to the end of the field and drop a cone every time I say 'now!'" The next time I said 'now!' there would be two people (you and the next person) dropping a cone. The third time I said it, there would be three people... etc.
You have the goal actor destroying when it reaches the end of the screen (the end of the field in my analogy). One way to fix this is to destroy the goal actor after it spawns obstacles.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang I have an obstacle that is about 4x width of a standard obstacle. What I am trying to do is when this obstacle is spawned delay the spawning of the next obstacle. Essentially obstacles will be spawning every 2 seconds but when bigger obstacle is spawned the next one should spawn after say 3 second instead of 2 so that there is same gap in between obstacles.
Any insight how this could be accomplished? I tried adding a rule to the timer in the controller that when obstacle.random=2 after 1 second spawn the goal. That doesn't seem to work though.