Behavoir in Nested Rules are always happening even when they aren't true

mcmunchlymcmunchly Member Posts: 2
edited March 2012 in Tech Support
I have an actor which I want to move diagonally towards the bottom of the screen.

When the actor spawns it checks if it is beyond the halfway across of the screen (in the X direction) and this determines if it moves diagonally left or right.

I have this behavior setup like this:

-----
RULE--
self.stop = 0
change attribute: self.stop += 1 // direction is no longer 0
NESTED RULE--
if self.position.x > device.screen.width / 2
direction = 225
OTHERWISE --
direction = 315
----

---
NEW RULE--
move
self.direction with constant speed
---

When I test this however, the nested rule gets evaluated every frame, as if the first rule does not even exist. The direction constantly juggles so the actor gets to the middle of the screen and just twitches left and right.

I made sure to put that change attribute so stop equals 1 which does work. self.stop only gets incremented one time, but the rule following it still gets evaluated even though it shouldn't by the logic of the programming.

I took a screenshot if somebody wants to look at as well, but I can't figure out how to include it in this post.

Comments

  • POMPOM Member Posts: 2,599
    edited March 2012
    You need to make a self attribute "self.Move Now"

    Then in your rule :
    ---
    When "self.stop" = 0
    Change "self.Move Now" TO true
    ***Otherwise
    Change "self.Move Now" TO false
    ---

    Now wrap your "move" rule in a rule (did i just said the word rule like a 100 times :) )
    ---
    When "self.Move Now" IS true
    move
    self.direction with constant speed
    ---

    Photobucket Roy
  • mcmunchlymcmunchly Member Posts: 2
    That isn't quite the fix I needed but it did make me realize a different way to get this to work so thanks!

    I think my original problem is a bug with Gamesalad though because I've seen other people with the same problem.
  • POMPOM Member Posts: 2,599
    Inspiration is always good :)

    Photobucket Roy
  • MotherHooseMotherHoose Member Posts: 2,456
    " RULE--
    self.stop = 0
    change attribute: self.stop += 1 // direction is no longer 0 "
    *** at this point the condition for the rule is no longer valid … and the computer ignores what follows ***
    ----
    Otherwise:

    --Rule: when
    --Attribute: self.position.x > device.screen.width / 2
    ---changeAttribute: self.direction To: 225
    --Otherwise:
    ---changeAttribute: self.direction To: 315

    ===
    move behavior
    --self.direction with constant speed

    ===
    I took a screenshot if somebody wants to look at as well, but I can't figure out how to include it in this post.
    the image must be uploaded on a website (mediafire or dropbox or your site or …)

    then you copy a link and paste in your comment
    image

    @};- MH
Sign In or Register to comment.