How to change colour of actor if rule is met.

I'm trying to get an actor to make a gradual colour change when colliding with another actor. I have it so far that if actor A collides with actor B it changes to one colour, but how do I get actor A to change to a second colour when it collides with actor B again? is it as simple as just adding another rule?

Comments

  • CatGoneCrazyCatGoneCrazy Member, PRO Posts: 90

    You could make an attribute within A that counts upwards every time it collides with B. Then refer to that with rules that specify what the colour should be at each stage of the count. If it gets too big, add a behaviour that says if bumpcount=>10 change bumpcount to 0. Then it will go round again. Hope that helps.

  • Fuller0810Fuller0810 Member Posts: 5

    @CatGoneCrazy said:
    You could make an attribute within A that counts upwards every time it collides with B. Then refer to that with rules that specify what the colour should be at each stage of the count. If it gets too big, add a behaviour that says if bumpcount=>10 change bumpcount to 0. Then it will go round again. Hope that helps.

    Would I make it a Change Attribute or a Constrain Attribute? That does make sense, just not exactly sure how to set that up. Would I do it by creating a new counter that isn't visible so I could put:

    Rule:

    Actor receives event - Overlaps or collides - with - Actor of type - Actor B

    Change Attribute: Game.Counter - to - Game.Counter+1

    From that I don't know how I would set it to

    if game.counter = +1, change to colour ...
    if game.counter = +2, change to colour ... etc?

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @Fuller0810 said:
    if game.counter = +2, change to colour ... etc?

    You would make the counter in Actor A, and you would use a change attribute behaviour as you describe (change count to count+1)

    You would then simply make some rules.

    If count attribute = 1 then change colour to . . .

    If count attribute = 2 then change colour to . . .

    If count attribute = 3 then change colour to . . .

  • Fuller0810Fuller0810 Member Posts: 5

    Worked great thank you both!

Sign In or Register to comment.