Random spawn question

dee99dee99 Member Posts: 100
edited November -1 in Working with GS (Mac)
How can I spawn a random actor at random intervals of time coming from one spawn point?

Comments

  • sandisctsandisct Member Posts: 2
    Maybe you can learn from this youtube tutorial...



    For the time maybe you can use the same concept for the spawntime by changing it randomly too.
  • RHRH Member Posts: 1,079
    create you actor 'spawn point' and create the actor you want to spawn (character).

    on 'spawn point' add a timer that

    every: random(3,7) seconds

    spawn actor: character

    Obviously you can change 3 and 7 to suit you.

    This will spawn and actor 'character' randomly every 3 to 7 seconds at spawn point. I'm not too sure how random it is thought because I often see patterns.
  • dee99dee99 Member Posts: 100
    Yes but how can I spawn a random character at that random time?
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    Have an integer game attribute set to 0. Call it random (or anything you like!)

    Create another actor and make it invisible (set its alpha to 0).

    In this "clear" actor add a timer and set it to every 5 seconds (or how often you want a random actor to spawn) change attribute game.random to random(1,5). This is assuming you have 5 different characters to spawn. If you want it to randomly choose between 7, make that random(1,7).

    Now inside this same actor, create 7 rules:
    if game.random = 1, spawn character 1

    if game.random = 2, spawn character 2

    ...and so on...

    You can specify the position for each actor to spawn when you use the spawn actor behavior. If you want this position to be the same at ALL times, just create 2 more game attributes called spawnX and spawnY, and set their values to the position you want to spawn at and in the spawn actor behavior set the x and y to game.spawnX and game.spawnY.

    Just drag this actor onto the scene anywhere, and it wont show up because it is "invisible" but it will continue to update the timer.

    This will randomly pick between the specified actors and spawn them at a predetermined locations.

    Hope this helps!
  • dee99dee99 Member Posts: 100
    Thanks for the help, I will try that
  • forkliftforklift Member Posts: 386
    Nevermind, sorry.
Sign In or Register to comment.