How do i spawn enemies in a scene

yoyox120yoyox120 Member Posts: 20
edited November -1 in Working with GS (Mac)
I want to spawn enemies in the start of a game so say at level 1 there is 10 2 there is 20 etc etc.. I know how to limit the numbers as i seen this video but i cant find one to show you how to make the enemies spawn and follow you so that if they hit you they explode and your health depletes. thank you

Comments

  • latygo60latygo60 Member Posts: 27
    The fact that they are "enemies" doesn't change anything...

    To spawn the 'enemy' actor, you just have to put a Spawn behaviour to an actor that will generate the enemies that you can position outside the camera.
    Or also you could try recycling the enemies:

    Also you have to create an integer attribute to count the enemies created, and this attribute should have the number of enemies that you want to generate.
    Then, every time that a enemy is generated, you have to Change Attribute:"enemies" to "enemies - 1". And keep generating enemies until 'enemies'= 0. You can have a Timer to control the spawning (check "Run till completion") putting the Rule inside.

    If you make a game attribute, when you finish a level, you have to change the enemies attribute to the number of enemies that you want to have on the next level before changing the scene.

    You could also make the enemies attribute a scene attribute, and have one different with the number of enemies in each level.

    Then, on the enemy actor you'll have a rule that Destroys the enemy when overlaps the player actor.

    Hope it helps.
  • yoyox120yoyox120 Member Posts: 20
    Thanks this kinda helps ill try to kinda digest all this cos as i said im new and get back with the results cheers mate :)
  • yoyox120yoyox120 Member Posts: 20
    Ok so i kinda understand but can you put this info into a nice step by step format as it would be most useful then
    thank u and sorry 4 my noobiness :LL
  • yoyox120yoyox120 Member Posts: 20
    R u still there ? Anyway ive looked into recycling but it just doesnt seem like it will work for me as he is doing it for a point and click thingy, oh god im really confused wayyy too overwhelming :(
  • latygo60latygo60 Member Posts: 27
    If you could explain a little the thing you want to achieve then I could be more specific with the explanation, and tell you step by step what you have to do :) But I'll try with what you said.

    First you have to create three actors:

    Player, Enemy and Enemy Generator.

    And three attributes:

    Player X, Player Y and Enemies.

    Place the player on the scene. The enemy generator have to be on the scene too but outside the camera view.
    You can go to the Scene tab and in the size of the scene make it a bit bigger and keep the camera size.

    Then you have both placed, let's go to the Enemy generator attributes.
    Under physics, you have to uncheck 'Movable' and if you want you can also check 'Fixed rotation'.

    Now the Rules. Drag a 'Timer' and check "run til completion". Inside the timer create a rule.
    The Rule have to say
    When attribute enemies is > 0. Then drag a "Spawn actor" behaviour and select the Enemy actor and the position and direction you want it to have.
    Also drag a 'change attribute' behaviour -> change 'game.enemies' to 'game.enemies - 1'
    Now for the specified numer of enemies, you have to change the attribute enemies for the desided number of them in the Game Attributes tab.

    The Player actor.
    Drag two 'constrain attribute' behaviours, you have to use them to track the player position.
    constrain: 'game.Player X' to 'self.positionX' and 'game.Player Y' to 'self.positionY'

    Then you need to have a Rule to control the player, tell me how do you want to move it and I'll tell you how to do.

    The enemy actor.
    Drag a 'move to' behaviour. On the X axis, tell it to go to 'game.Player X' and on the Y axis to 'game.Player Y'.
    You have to select the speed lower than your movements.
    Create a Rule: When overlaps or colides the 'player actor'.
    Drag a "destroy this actor behaviour and a Change attribute saying 'change 'game.enemies' to 'game.enemies-1'

    I think that's pretty much all you have to do.
    Hope it helps
  • yoyox120yoyox120 Member Posts: 20
    Oh cheers ill check that out when im free. Cheers bud :))
  • yoyox120yoyox120 Member Posts: 20
    Is the enemy attribute an integer or real or what type is it ?
  • yoyox120yoyox120 Member Posts: 20
    Dont worry bout controlling him cos the template im using already covers that
  • yoyox120yoyox120 Member Posts: 20
    Umm it doesnt work 4 sum reason the whole limit thing doesnt work plus when he spawns he just moves on to the bottom left corner of the scene ?
  • yoyox120yoyox120 Member Posts: 20
    Oh and he also doesnt spawn with the time set on the timer i have to make it spawn with a keyboard button
  • yoyox120yoyox120 Member Posts: 20
    UPDATE: so i have fixed the spawn thingy and it only spawns 10 but then again I cant get the enemy to follow even though i do what you say :(
  • latygo60latygo60 Member Posts: 27
    I tried what I told you and it works for me.

    Make sure you playerX&Y attributes are Real.

    Let me know if it works :)
  • informedstudiosinformedstudios Member Posts: 18
    *sigh* I am having so much trouble with this. Every time I put all of the Behaviors onto the Enemy and come back, my text is cleared out.

    image

    Am I just doing this completely wrong?

    I also couldn't find where to do this:

    Drag a "destroy this actor behaviour and a Change attribute saying 'change 'game.enemies' to 'game.enemies-1'
  • latygo60latygo60 Member Posts: 27
    Hey! Try instead of click Back, going to 'Scenes' and choosing the scene you were working on.

    The behavior to destroy is called "Destroy". You have to put in the actor you want to be destroyed, inside a rule, with the condition: When 'ovelaps or colides' actor 'player'.
Sign In or Register to comment.