GameSalad

Spawning actors with random attributes other than location?

Hello everyone,

My son (8) has taken up an interest in making video games and I'm trying to teach him using GameSalad. We've got a simple "balloon popping" game going where every second a balloon actor is spawned at the bottom of the screen and floats to the top and you try to pop it.

I get that "spawn actor" can be given a random x,y position and we're using that. I'm wondering if there is a way to randomize other attributes? For instance I'd like to change the physics of each balloon so that they rise at different rates, or given them a little random angular velocity so they look like they're floating back and forth.

But I have no idea how to do this. I tried giving my actor an "initialized=false" attribute and then setting up a rule that, if initialized==false, sets these attributes randomly and then sets initialized=true. But then all my balloons just get the first initial set of random values, instead of each having its own values. I figure it's because the second time I call Spawn, the initialized value is now true?

Every time I google anything related to spawn, actor and random I get the "make a bunch of different actors and then use a random value to decide which one to spawn", but this isn't really that. I'm not looking to create a dozen different actors, I just want a bunch of red balloons that happen to be moving a little differently from each other.

Can I do this? Or am I limited to making a fixed set of a dozen variations of my balloon and then doing the "If random==1 then spawn balloon1" thing?

Comments

  • RossmanBrothersGamesRossmanBrothersGames Posts: 648Member, PRO

    Yes you can do this. I'm not sure how your behaviors are set up but for the rising behavior you could use

    Change attribute:

    Vertical Velocity to Random(100,200)

    Something like that, play around with it

  • @RossmanBrothersGames said:
    Yes you can do this. I'm not sure how your behaviors are set up but for the rising behavior you could use

    Change attribute:

    Vertical Velocity to Random(100,200)

    Something like that, play around with it

    Yes but when do I set that, is the question. I have an "every 1 second Spawn Actor of type Balloon" rule. That Spawn Actor behavior lets me specify a random position and direction. Since I'm relying on negative gravity to float my balloons up up and away I'm not sure if i can use direction to my advantage. Where would I add the changing of an arbitrary attribute?

    I've got an invisible "Spawner" actor that is doing the timer. I thought about adding the timer behavior to the Balloon actor (so that I could change self attributes), but during the course of the game the player will pop/destroy all the actors on the screen so I didn't think that would work.

  • RossmanBrothersGamesRossmanBrothersGames Posts: 648Member, PRO

    Put that rule in the balloon actor. And don't use the direction in spawner. If that rule is in the balloon it will set the speed randomly right when the balloon is created, and will only affect that balloon

  • tatiangtatiang Posts: 11,085Member, Sous Chef, PRO, Senior Sous-Chef

    @RossmanBrothersGames said:
    Put that rule in the balloon actor.

    Right. Any actor-specific attribute values you want to generate should be at the top of the balloon actor's rule list. They do not need to be inside of a rule unless you have a good reason to do so.

    The idea is that the spawner actor will spawn the balloon actor at whatever position you decide and then the balloon actor will go through its rule list. If the top of its rule list include a bunch of Change Attribute behaviors, these will set various values immediately and everything else the balloon actor does will be based on those values. Just make sure you're changing actor attribute values (e.g. self._____) and not game attributes.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Putting the rule in the actor, and some random initializing statements ahead of all my rules, did the trick!

    Because as I noted it's possible for all the balloon actors to be destroyed, I created an invisible instance of a balloon, fixed its position and made it not responsive to a button click, so basically it stays active forever even if all the other balloons have popped.

    Thanks for the help!

  • obinna7obinna7 Posts: 4Member, PRO

    Doing something similar.
    dmorin could you share your rules to help me better understand how you got it working.
    Thanks.

  • pHghostpHghost London, UKPosts: 2,106Member

    Please do not revive old threads like this.

    @dmorin@gmail.com has not been active on the Forums since 2014 and is very unlikely to answer your question.

    If you have a query, start a thread of your own where you explain what you need in more detail.

Sign In or Register to comment.