2 Identical Actors collide to make 1 big one

allornothingallornothing Member, PRO Posts: 126
edited November -1 in Working with GS (Mac)
So i've came to bit of a mental block here and I'm hoping someone can help:

I've set up a scene where instances of an actor are spawned in regularly. The player can touch and drag these actors around, and the idea is that if they collide with one another, they 'merge' into one larger actor. My first attempt:

On collision with the actor type, the actor is destroyed and the new large actor spawned in its place. However as this is on both actors, i just spawn 2 large actors. How can I have two identical actors collide and spawn 1 new type?

Hair. Pulled.

(other than that, really enjoying my first game with GS, so much fun!)

Comments

  • calvin9403calvin9403 Member Posts: 3,186
  • design219design219 Member Posts: 2,273
    I see the problem. You might try making an integer attribute and a rule that says the integer has to be an even number for the new larger actor to spawn, and each collision increases the number by one. That way, the first will add one, making the attribute an odd number and not spawn, but the second will add one and make it even again so the larger actor will only spawn from the second.

    Just a thought, may not work.
  • allornothingallornothing Member, PRO Posts: 126
    @calvin9403 - would if i could mate! but if the actors are identical, with a rule to spawn a new bigger actor - then i'll get two wont I? :)

    @design219 - Interesting, could work yeah. I get the logic definitely - although would the collisions be handled simultaneously? or will one precede the other?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    here's another thing to try. You can give each actor a unique "ID" by doing this:

    1) create a game integer attribute - game.actorcount
    2) in the actor being spawned create a self integer attribute - self.actorID
    3) in the actor being spawned have these two behaviors at the top:

    change game.actorcount to game.actorcount + 1
    chage self.actorID to game.actorcount

    4) create a game integer attribute - game.currentlyGrabbed
    5) back in the actor being spawned add this rule to the dragging rules that you are currently using:

    change game.currentlyGrabbed to self.actorID

    Then have a rule that says

    when collides with actor AND
    self.actorID ≠ game.currentlyGrabbed
    destroy
    OTHERWISE
    change width to blah blah (double the width)
    change height to blah blah
    change image (maybe??)

    Haven't tried it but it should work.

    good luck
  • calvin9403calvin9403 Member Posts: 3,186
    why not go to the scene(where you can see the actor) and change them
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    calvin9403 said:
    why not go to the scene(where you can see the actor) and change them

    they're being spawned. so they're not in the scene until run time.
  • calvin9403calvin9403 Member Posts: 3,186
    got it

    ________________________________________________________________________________________________
    http://www.gamesaladforum.com/
    http://gshelper.com/
    http://www.youtube.com/user/GameSaladCookbook#p/
Sign In or Register to comment.