Rule that responds to attribute value change

Hi, I'm new to GameSalad and I hope this issue I've found is just a newbie-type error, but I'm very stumped at the moment. I have a blank actor with a rule in it that responds to changes in a game attribute value, screen_num. The value is changed by hotspots that the user clicks. The rule has a behavior that moves the camera origin.x so that the proper "screen" is shown, based on the value of screen_num. (I have six screens, side by side, in my scene. The first one is the master shot and the others are all close-ups of individual objects.)

All this works fine until the camera moves to one of these other screens. The problem occurs when one of these other screens also has a hotspot on it (to zoom even further in to the object, say). The hotspot on this new screen changes the screen_num value (I'm confirming this with the debugger) but the blank actor with the rule that "listens" for that change doesn't respond to the change. Even stranger, it does respond in one case: if that hotspot changes the value back to zero, then it responds (which takes you back to screen zero, the master shot.)

All the hotspots are the same -- they are all using the prototype actor. There is one integer attribute in the prototype, screen_id, that each hotspot overrides with a unique value.

I'm going nuts trying to figure this out. Any help or ideas or suggestions would be extremely welcome.

Comments

  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    I'm having a hard time thinking of a way to explain this, so here is a step by step example.

    Attribute starts at zero. Rule checks when attribute != 0.
    Attribute gets changed to 1. Rule fires.
    Attribute changes to 2. The rule is still true, but it won't activate.
    Attribute changes back to 0, rule is now false.
    Attribute changes to 3, rule is true and fires.

    Basically, in between true calculations, the rule needs to go back to false.

    Have the invisible actor track screen_num locally.

    Change Attribute->local_screen_num ->screen_num
    Then underneath that:
    Rule When Attribute local_screen_num does not equal screen_num
    (Stuff that happens in rule)
    Then at the bottom of the rule-
    Change attribute->local_screen_num->screen_num

    Sorry if that's a little confusing, haven't had my coffee yet.
  • icemacseaicemacsea Member Posts: 9
    I see. That makes sense. The rule is not really listening for a change in the attribute value. It's just geting evaluated (every frame, I assume) to see if it's true or not. And the rule only fires when the system detects that it has gone from false to true.

    It's like you have to "reset" that rule to get it to fire again. Thanks so much for your help!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    I see. That makes sense. The rule is not really listening for a change in the attribute value. It's just geting evaluated (every frame, I assume) to see if it's true or not. And the rule only fires when the system detects that it has gone from false to true.

    It's like you have to "reset" that rule to get it to fire again. Thanks so much for your help!
    That's exactly right. A When [condition] rule checks to see if the condition changes, not if the value within the condition changes. So if it's true (e.g. When self.position.X>200) and the value changes but the condition does not (e.g. self.position.X changes from 250 to 300), then the rule does NOT fire again.

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

Sign In or Register to comment.