GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to spawn actors in front of moving Hero?(fixed)

ohtukrwohtukrw Sir dogePosts: 106Member
edited July 2016 in Help Wanted

I have a hero that is always moving to right x direction and is jumping so Y axis position change as well.

I want some actor coins to spawn in front of my hero at random x position within the visible scene.
Also coins that are not collected should be destroyed once they are off the visible screen.

How can I do that and do I create a separate spawner or place the rules inside the hero?

Thanks. :blush:

Comments

  • UncloudedStudioUncloudedStudio NetherlandsPosts: 285Member
    edited July 2016

    Hi @ohtukrw

    Create a separate actor to spawn your coins and/or other obstacles.

    Place a timer and set it to every 1 seconds.
    Place a spawn behavior in that timer to spawn the coins.
    You can spawn in random locations by setting the x/y position to a random number like so; random(10,500)

    You can also do this for the timer to randomize the spawn time.
    e.g. for every random(1,3) seconds spawn....

    Change the values as you see fit.

    To destroy the coins that the hero has missed you can place a wall outside the screen and when the coins collide with the wall, destroy the coins.

    Hope this helps :)

  • ohtukrwohtukrw Sir doge Posts: 106Member

    @UncloudedStudio said:
    Hi @ohtukrw

    Create a separate actor to spawn your coins and/or other obstacles.

    Place a timer and set it to every 1 seconds.
    Place a spawn behavior in that timer to spawn the coins.
    You can spawn in random locations by setting the x/y position to a random number like so; random(10,500)

    You can also do this for the timer to randomize the spawn time.
    e.g. for every random(1,3) seconds spawn....

    Change the values as you see fit.

    To destroy the coins that the hero has missed you can place a wall outside the screen and when the coins collide with the wall, destroy the coins.

    Hope this helps :)

    Hi,
    I have a big scene, so I would prefer them to spawn where ever the hero is at that moment. So I guess I should place the spawner inside the hero?

  • NNterprisesNNterprises Posts: 387Member, PRO
    edited July 2016

    @ohtukrw said:"Hi,
    I have a big scene, so I would prefer them to spawn where ever the hero is at that >moment. So I guess I should place the spawner inside the hero?"

    Put spawn command in the actor, and Spawn "relative to actor" instead of scene

Sign In or Register to comment.