Spawn same actor at random sizes

Games!Games! Member, PRO Posts: 11

Hi, i want to spawn an actor every 1 second. That's fine. But now I want the actor spawned to be a random size.

For example after 1 second it spawns the actor at size 10x10, then one second later it will spawn another but this time a different size (random) eg 30x30.

Thanks for any input!

Comments

  • ThoPelThoPel GermanyMember, PRO Posts: 184
    edited July 2015

    The two behaviors ensure that it is always a square with a size between 10 and 30.

  • Games!Games! Member, PRO Posts: 11

    Thank you this worked! I had to add a timer with a "for" x seconds to ensure that the each spawned actor remains their respective size.

    Thanks so much for your quick reply too!

  • Games!Games! Member, PRO Posts: 11

    Now that that's been solved i need some more help >.> I want my other actor to destroy the random spawned actor (described above) ONLY if it is bigger than the one it collided with- how can I do this.

  • ThoPelThoPel GermanyMember, PRO Posts: 184
    edited July 2015

    @Games! I would set the default size to 0/0 and add a rule
    "If width = 0 and height = 0 then random size"
    So the size is defined only one time. If the "for"-timer has a to large value the runtime-loop could execute it multiple times.

  • Games!Games! Member, PRO Posts: 11

    Not sure if you understand or perhaps I don't.

    There are 2 actors
    1: "Main"
    2: The spawned actors which are all random sizes

    I want it so the if actor 1 overlaps with actor 2 it will destroy actor 2, but only if actor one is bigger than actor 2.

    I tried saving number 2's width in a game attribute enemy size and then using it if actor 1 width> enemy size width.

    However the enemy size width is constantly updated with the new spawns.

    As a result my main character can sometimes destroy actor 2 even when its larger, or fail to destroy even when its smaller.

    I want the enemy size width to be respective to each of the different spawns so this problem doesn't happen.

  • ThoPelThoPel GermanyMember, PRO Posts: 184

    I understand your problem, but until now I did not know what you are building :-) My last post was just a example how I would randomize the actor 2 size.

    You need a logic for the actor sizes. Are you using tables for the actor sizes?

  • Games!Games! Member, PRO Posts: 11

    Ok perhaps this is beyond me and will be a lot for you to help me with. I don't know how to use logic functions and tables so i guess I should try learn that? If so, would you be able to direct me towards any material you recommend I check?

  • ThoPelThoPel GermanyMember, PRO Posts: 184

    @Games! I would search for a example game in this forum or the known shops:

    www.deepblueapps.com
    www.gsinvention.com
    www.gshelper.com

    Don't develop something a second time, just buy the template for 5 or 10 $ and relayout it.

  • bogatechbogatech AustraliaMember, PRO Posts: 3

    Hi guys,
    I'm trying to spawn an actor every so often at a random interval between each spawn. E.g. The actor would spawn once and then after a random period of time (say 1.5 seconds) it would spawn again, and this process would be repeated with a different random time interval each time (the next one might be 3 seconds).
    The problem is at the moment I am using:
    Timer: every: random(1.5,3) spawn actor
    This means that it picks a random value and spawns the actor at equal intervals at that value until the scene ends. What would I be able to do to get the desired effect?
    Thanks!

Sign In or Register to comment.