Behavoir in Nested Rules are always happening even when they aren't true
mcmunchly
Member Posts: 2
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.
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
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
---
Roy
I think my original problem is a bug with Gamesalad though because I've seen other people with the same problem.
Roy
--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
=== 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
@};- MH