Random Function (for spawn locations and random spawnings)
Kamazar
Member Posts: 287
Got yet another question, is there a random function somewhere? I'm trying to do two things.
1) Be able to create random locations for the enemy to spawn off-screen (kinda interferes with destroying my enemies once they leave the screen, but I'll try to fix that later), but are somehow not too far away from their target. If I create actors that spawn for me, it makes the game predictable, which breaks down what I'm trying to do.
2) Make the spawn times random. I don't want a steady stream, otherwise there'd be a flood of enemies from nearly every direction.
These both need a random function, and the Timer behavior doesn't even have a formula line. If this can somehow be found out, I'm even willing to write a Wiki for it. This is crucial for several types of games.
I tried creating some x>x game attributes to use with actors, but none of the settings support them.
1) Be able to create random locations for the enemy to spawn off-screen (kinda interferes with destroying my enemies once they leave the screen, but I'll try to fix that later), but are somehow not too far away from their target. If I create actors that spawn for me, it makes the game predictable, which breaks down what I'm trying to do.
2) Make the spawn times random. I don't want a steady stream, otherwise there'd be a flood of enemies from nearly every direction.
These both need a random function, and the Timer behavior doesn't even have a formula line. If this can somehow be found out, I'm even willing to write a Wiki for it. This is crucial for several types of games.
I tried creating some x>x game attributes to use with actors, but none of the settings support them.
Comments
random.
Alright, I have another question/problem. I set the spawn instruction so that the location of said spawning would occurs between or equal to the X points 320 and 420 and Y points 0 and 480. In other words, the spawning occurs above the screen. Now, my question is, every time there's a spawn, is a new number (for the X and Y coordinates) generated, or are the same coordinates used? Cuz I keep getting enemies coming in from the same location, which obviously is a problem. Has anybody that's done random spawns before help me out on this one?
In this actor, I use a timer, so that every 2 seconds, it spawns an enemy at a random location.
Then every 7 seconds, it spawns a different enemy at random coords.
I think because the random function is called with the timer it comes up with a new set of coords ever time. Seems to work ok - you can see it in effect in my Sol demo here: http://gamesalad.com/game/play/4569
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
And yeah, I use a controller to. Oughta be the first trick a rookie learns. Keeps everything a little more organized The timer's currently set for every 5 seconds, so if your theory's true, I shouldn't have a problem. Nice demo, BTW. Really like the cross hairs.
So, yeah... thx, JG and QS. Hopefully I won't have anymore questions 'til I get my first playable demo up and running.
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io