Randomly Spawning Actor
FastlaneSuccess
Member Posts: 46
Let says I want an actor to spawn randomly at Y 0-20 and 60-100, but never inbetween 20 and 60. How do I formulate this?
Comments
One method:
Change attribute self.random to random(1,2)
When attribute self.random=1
Change attribute self.spawnY to random(0,20)
When attribute self.random=2
Change attribute self.spawnY to random(60,100)
Spawn [actor] at [x] and self.spawnY
It's not ideal because it gives equal weight to both ranges.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Ok, I should have said that I have a An Actor (Spawner) that spawns my other actor. I put all of what you said in the Spawner but made the Behavior spawn actor - spawn my other actor. Both random and spawnY I assumed are integers that I made within the spawner. Don't know what I did wrong, but it keeps spawning in the same spot. I also put a timer to spawn it every second. But if this were to work, wouldn't each game session just choose 1 or 2 but never interchange between both within a game session?
I'm not sure what all of that means, to be honest, but try this demo. I imported a csv file with all possible Y values.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User