Platformer Template Glitch Fixed, But Now Jumping Problem. Need Suggestions.
![Gallardo](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I appreciate the help guys, first post here in the forum. I need help jumping and facing the correct direction. I want to jump and change pose states without using a boolean attribute. I believe the boolean player attribute FacingRight is causing a problem in the platformer template. However, now that I fixed that (in my own project) I can't make the player face the desired direction while jumping up and down, and the direction is sometimes wrong. (Jumping left I get the character facing right).
Here is what I did to replace the FacingRight boolean player attribute in the Platformer Template which stopped the pose glitching.
Open the platformer template. Open the preview and move the player left and right with the arrow keys. Notice that when the player comes to a stop, the player changes its pose state for a split second and faces the opposite direction. This was driving me crazy. It almost made me quit after having just started using Gamesalad. My solution: I created an integer game attribute, call it MovPhase. Odd numbers are for running/at rest facing left, and even numbers are for running/at rest facing right; number 2 means you are running right and number 4 stopped and facing right. Here are my rules:
First Rule (Move Left Command):
Key left is down
Change Attribute: game.MovPhase = 1
Otherwise
Change Attribute: game.MovPhase = 3
Second Rule (Move Right Command):
Key right is down
Change Attribute: game.MovPhase = 2
Otherwise
Change Attribute: game.MovPhase = 4
Left Movement Attributes:
game.MovPhase = 1
self.grounded = true
Constrain Attribute:
Self.Motion.Linear.Velocity.X. to -self.Motion (Player Integer Attribute Motion = 175)
Animate: (Running Left)
Right Movement Attributes:
game.MovPhase = 2
self.grounded = true
Constrain Attribute:
Self.Motion.Linear.Velocity.X. to self.Motion (Player Integer Attribute Motion = 175)
Animate: (Running Right)
Stopped Facing Left Attributes
Attribute: game.MovPhase = 3
Constrain Attribute: self.Motion.Linear.Velocity.X = 0
Change Image: (Player Facing Left)
Stopped Facing Right Attributes
Attribute: game.MovPhase = 4
Constrain Attribute: self.Motion.Linear.Velocity.X = 0
Change Image: (Player Facing Right)
There it is. With that the platforming character should no longer face the opposite direction for a split second when coming to a stop. However now I fear that this solution is creating problems for me when I am jumping. I need someone to look at my rules and tell me what I can do to be able to:
Jump while:
1. Stopped and facing right while having one pose state in air.
2. Stopped and facing left and having a different pose state in air.
Currently, if I jump while I am stopped, I see the images from Mov.Phase 3 and 4, which are stopped and facing either left or right. Also when I jump up and down I can only fall straight down and cannot fall towards the left or right.
I would like to be able to:
1. Hit right arrow key while jumping and fall rightwards in air, while keeping the same pose state I used to jump right.
2. Hit left arrow key while jumping and fall leftwards in air, while keeping the same pose state I used to jump left.
Here are my rules for jumping:
Key: Space is down
Attribute: self.inAir is False
Change Attribute: self.Motion.Linear.Velocity.Y to 275
Rule:
Attribute: self.Motion.Linear.Velocity.Y (not equal to symbol) 0
Attribute: self.Motion.Angular.Velocity (not equal to symbol) 0
Change Attribute: self.inAir = true
Otherwise: self.inAir = false
I also have gravity at 600,
colliding with ground,
determine if grounded:
overlaps or collides with ground
self.grounded = true
otherwise self.grounded = false
I will really appreciate it if one of the gurus or anyone with experience can take a look at this and tell me how to change my rules to get what I need. I also want to know if my fix for the platformer pose state glitch is the simplest way of correcting the problem. Thanks.
Here is what I did to replace the FacingRight boolean player attribute in the Platformer Template which stopped the pose glitching.
Open the platformer template. Open the preview and move the player left and right with the arrow keys. Notice that when the player comes to a stop, the player changes its pose state for a split second and faces the opposite direction. This was driving me crazy. It almost made me quit after having just started using Gamesalad. My solution: I created an integer game attribute, call it MovPhase. Odd numbers are for running/at rest facing left, and even numbers are for running/at rest facing right; number 2 means you are running right and number 4 stopped and facing right. Here are my rules:
First Rule (Move Left Command):
Key left is down
Change Attribute: game.MovPhase = 1
Otherwise
Change Attribute: game.MovPhase = 3
Second Rule (Move Right Command):
Key right is down
Change Attribute: game.MovPhase = 2
Otherwise
Change Attribute: game.MovPhase = 4
Left Movement Attributes:
game.MovPhase = 1
self.grounded = true
Constrain Attribute:
Self.Motion.Linear.Velocity.X. to -self.Motion (Player Integer Attribute Motion = 175)
Animate: (Running Left)
Right Movement Attributes:
game.MovPhase = 2
self.grounded = true
Constrain Attribute:
Self.Motion.Linear.Velocity.X. to self.Motion (Player Integer Attribute Motion = 175)
Animate: (Running Right)
Stopped Facing Left Attributes
Attribute: game.MovPhase = 3
Constrain Attribute: self.Motion.Linear.Velocity.X = 0
Change Image: (Player Facing Left)
Stopped Facing Right Attributes
Attribute: game.MovPhase = 4
Constrain Attribute: self.Motion.Linear.Velocity.X = 0
Change Image: (Player Facing Right)
There it is. With that the platforming character should no longer face the opposite direction for a split second when coming to a stop. However now I fear that this solution is creating problems for me when I am jumping. I need someone to look at my rules and tell me what I can do to be able to:
Jump while:
1. Stopped and facing right while having one pose state in air.
2. Stopped and facing left and having a different pose state in air.
Currently, if I jump while I am stopped, I see the images from Mov.Phase 3 and 4, which are stopped and facing either left or right. Also when I jump up and down I can only fall straight down and cannot fall towards the left or right.
I would like to be able to:
1. Hit right arrow key while jumping and fall rightwards in air, while keeping the same pose state I used to jump right.
2. Hit left arrow key while jumping and fall leftwards in air, while keeping the same pose state I used to jump left.
Here are my rules for jumping:
Key: Space is down
Attribute: self.inAir is False
Change Attribute: self.Motion.Linear.Velocity.Y to 275
Rule:
Attribute: self.Motion.Linear.Velocity.Y (not equal to symbol) 0
Attribute: self.Motion.Angular.Velocity (not equal to symbol) 0
Change Attribute: self.inAir = true
Otherwise: self.inAir = false
I also have gravity at 600,
colliding with ground,
determine if grounded:
overlaps or collides with ground
self.grounded = true
otherwise self.grounded = false
I will really appreciate it if one of the gurus or anyone with experience can take a look at this and tell me how to change my rules to get what I need. I also want to know if my fix for the platformer pose state glitch is the simplest way of correcting the problem. Thanks.