Spawn Actor after condition

SunnySunny Member Posts: 12

Hi,

I currently have three actors, Block, Spawner, and Floor.

I would like to write rules for the spawner to spawn one block. The block will then fall to the floor, and once it hits the floor the spawner will spawn another block.

I can't seem to program the part where the spawner spawns ONE block after the block hits the floor.
What is the best way to solve this?

Thanks,
Sunny

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Hi Sunny,

    Try making a game boolean attribute and set it to true initially.

    In your spawner:
    When attribute game.Boolean is true,
    Spawn blowck
    Timer: After 0.1 seconds change attribute game.Boolean to false

    In your block:

    When overlaps or collides with floor,
    Change attribute game.Boolean to true.

    That should get you on the right track.

  • SunnySunny Member Posts: 12

    Yes i tried that, however after I drop the first block, it seems to keep spawning blocks instead of just spawning 1 block

  • WbokoWboko Tennessee, USAMember, PRO Posts: 621
    edited March 2014
  • SunnySunny Member Posts: 12

    Hey Wboko,
    Thanks for the reply
    However, I'm trying to make the "Mother" spawn a block only after the block hits the floor, not after the block leaves the "Mother".

    Thanks

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Code is logic. Think in logic. In your actor that hits the floor make a self integer let's call it spawn.

    Rule

    When actor overlaps and collides with floor and self.spawn = 0

    Spawn actor

    Change attribute self.spawn to 1

    The change attribute will change the condition of the rule so it will only fire once. Since code is scanned in the order it's placed from top to bottom the spawn fires first then the change next which changes the condition of the rule when it's scanned again. This all happens in milliseconds.

  • WbokoWboko Tennessee, USAMember, PRO Posts: 621

    @Sunny said:
    Hey Wboko,
    Thanks for the reply
    However, I'm trying to make the "Mother" spawn a block only after the block hits the floor, not after the block leaves the "Mother".

    Thanks

    That is cool, I tried to do what you are wanting, but the issue also ends up being how to stop the spawning at some point; plus if you set a timer you can expand out the spawning time frame.... Good Luck!

    @FryingBaconStudios said:
    Code is logic. Think in logic. In your actor that hits the floor make a self integer let's call it spawn.

    Rule

    When actor overlaps and collides with floor and self.spawn = 0

    Spawn actor

    Change attribute self.spawn to 1

    The change attribute will change the condition of the rule so it will only fire once. Since code is scanned in the order it's placed from top to bottom the spawn fires first then the change next which changes the condition of the rule when it's scanned again. This all happens in milliseconds.

    I think that will only fire once because there is nothing to change the 1 back to 0 and I like the Bool better myself....

  • SunnySunny Member Posts: 12

    Thanks for your replies,
    Here is what i currently have, see if you can fix it:

    For Block, When Block collides with Floor,
    Change attribute Respawn Block to True

    For Spawner, When Respawn Block is True,
    Spawn actor Block
    After 0.1 sec, change attribute Respawn Block to False

    This makes the spawner spawn lots of blocks instead of just one.
    I think it is doing this because the block, once it touches the floor, will always be touching the floor so keeps setting the attribute Respawn Block to true?

  • WbokoWboko Tennessee, USAMember, PRO Posts: 621

    Yep, that is why I use the Mother Template I sent you... Good Luck!

  • SunnySunny Member Posts: 12

    Thanks Wboko, anyone have any ideas on how to set it so it only spawns 1 block everytime?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I find booleans to be tricky at times I like integers as I can have a neutral position if I want and progress the number to trigger other possible conditions makes the code more expandable and slim. You need a trigger similar to what I showed.

    Make a game level integer attribute called spawn

    In your spawning actor

    Rule

    When game.spawn = 0

    Spawn actor

    Change attribute game.spawn to 1

    In the spawned block

    Rule

    When block overlaps and collides with floor

    Change attribute game.spawn to 0

  • SunnySunny Member Posts: 12

    For some reason that seems to fix the problem! Thanks! I agree using integer instead of boolean is good as it allows for more options

Sign In or Register to comment.