Spawning an actor from any 4 spawn points?

Macca_McGillMacca_McGill Member, PRO Posts: 108
edited November -1 in Working with GS (Mac)
Hi guys,
Basically i was wondering how to spawn an actor from any of the 4 spawn points i have set up. The 4 spawn points are 4 actors dotted around(named spawn1-4). Im guessing its having a game attribute called spawn as an integer, then wenever i want to, change attribute game.spawn to a random 1-4. Then have a rule if game.spawn = 1, spawn actor at x,y relating to that spawn point?
Am i on the right lines?

Thanks in advance.

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Yep thats how i would do it. Make it a self attribute in the object you want to spawn. Change self attribute randomPoint to random(1,4)

    then when randomPoint=1 change position or spawn wherever

    then when randomPoint=2 change position or spawn wherever

    ect..
  • imGuaimGua Member Posts: 1,089
    I use that method too.
    10-14 for one type of enemy. 20-24 for other etc.
  • Macca_McGillMacca_McGill Member, PRO Posts: 108
    Thanks for the help guys :)
  • Macca_McGillMacca_McGill Member, PRO Posts: 108
    im struggling lol. I have a game attribute called spawn point which is an integer. got it set up to ok. Got the 4 actors dotted around, but how do i tell the target to spawn at spawn 1, 2 etc?
  • LumpAppsLumpApps Member Posts: 2,881
    Ehm, I don't believe you need 4 actors as 'spawn points'

    Do this:
    Make a new actor. (and put it on the stage ;)
    Inside:
    Make a new integer attribute named 'spawnpoint'

    make a timer behaviour
    every 'X' secs (where X stands for the frequency you want the actors to spawn)
    change attribute 'spawnpoint' to 'random(1,4)'

    Then a set of rules
    when attribute 'spawnpoint' is '1'
    spawn actor 'actortospawn' (the actor you want to spawn)
    Then on position x and y you can enter the position of the 4 points you mentioned earlier.
    Make sure it is relative to scene and no actor.

    Do this last bit for all 4 spawnpoints

    Cheers,
    Ludwig
  • Macca_McGillMacca_McGill Member, PRO Posts: 108
    basically i have one target spawn off screen a specific point, got that working fine. Everytime one target is shot it will spawn a new target at any one of the 4 spawn points.
  • Macca_McGillMacca_McGill Member, PRO Posts: 108
    arghhhh after shooting the first target it doesnt spawn the next actor. Where am i putting the rules for game.spawnpoint = 1 spawnactor. On the stage or inside the target actor?

    Sorry for all the questions.
  • Macca_McGillMacca_McGill Member, PRO Posts: 108
    Thanks t-shirtbooth :)
  • Macca_McGillMacca_McGill Member, PRO Posts: 108
    well i have finally got it working thanks to t-shirtbooths template. I still have a bug that i cant for the life of me work out whats causing it. Every now and again after shooting the target, the next one wont spawn. Ive tried re-doing all the rules and actors but it still does it. Anyone had any problems like this in their games? I dont really want to release it with a bug in that stops you playing.
  • Macca_McGillMacca_McGill Member, PRO Posts: 108
    sorry to bump this again but can anyone help me? its the only thing thats stopping me releasing the game lol.
Sign In or Register to comment.