Independent Instance of Same Object

WindmarbleWindmarble Member Posts: 4
edited November -1 in Working with GS (Mac)
How can I prevent multiple copies of an actor from behaving the same way when clicked?

For example, say I have three squares, all colored blue, when I click one square it should change to red, but all the other squares change to red as well. I would just like the one I clicked to turn a different color.

I was hoping to reuse the same Actor with all its rules.

Comments

  • hrsmediahrsmedia Member Posts: 522
    I have a similar problem.

    I have a rule on Actor1 where after a few seconds Actor2 is spawned and Actor2 follows actor1. I have the constrain attributes on Actor1. So this works fine.
    But when another instance of Actor1 is spawned, Actor2 will start following the new instance of Actor1 rather than stay following the original Actor1 instance in the scene.
  • POMPOM Member Posts: 2,599
    the way i see it you have 2 options:
    1) you can create 3 different actors, each with individual rules.
    2) you can use the same actor but edit the actors in the scene itself (not the prototype) double click it on the scene
    with minor changes.

    hope it helps
  • hrsmediahrsmedia Member Posts: 522
    Can't edit the actors in the scene, because they spawn during the game.
  • RHRH Member Posts: 1,079
    how are you making it change colour? when touch is pressed change attribute: self.color.red (can't remember the name of the attribute) to XXX ?
  • POMPOM Member Posts: 2,599
    ok here is an advice.. if you spawn them in a NON random way so you can add a rule inside the spawned actor that say, if "self.position.x" is = the x where you spawn it, so change
    attribute - "self.what kind of actor am i" to 1, and then you have a rule,
    when touch is pressed AND when "self.what kind of actor am i" = 1 change color to red

    so that in the other actor which has a different X value, make the sam thing but change it to 2!
    and a rule, when touch is pressed AND "self.what kind of actor" = 2 change to blue!

    and so on... is that make any sense?
  • ORBZORBZ Member Posts: 1,304
    use an attribute within the actor that is unique to that instance.

    like an instance id (integer)

    have the id be autogenerated.

    a simple way to do it is:

    change attribute id = game.time * 1000 + random(100,5000)

    that's pretty unique
Sign In or Register to comment.