The Art of Jumping. Please teach me the ways.
![LearnTheGame](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Hello GameSalad community. First off, I'm new here, but the whole idea behind GS is so exciting. Anyway, I'll cut to the chase.
I have some questions about jumping for a platformer game. I looked through the wiki and some templates and found a few useful instructions, and I applied the demonstrated jumping code and with a few tiny tweaks it worked for my game for a while. Then, sometime later, I opened my project and the actor's jumping behaviors weren't the same. I'll try to describe what I did to make it work the first time, and then after I'll describe what changed. I can't figure out what caused the change.
First I created a game.attribute integer called Jump
I created jumping rule for my actor when receive key space bar, and attribute game.jump <2
change attribute to self.motion.linear.velocityY to 650
change attribute game.jump to game.jump+1 (this was to allow a double jump)
Then I created a rule to stop my actor from jumping when touching the ground if the space bar was held down. (I wanted the actor to only be able to jump again if the space bar was first released)
Rule: When actor overlaps or collides with Solid Platform
Constrain attribute game.jump to -1 (To stop the actor from continuing to jump when space bar was held down)
At first when I previewed this code it worked very well. My actor had a double jump and if the space bar was held down the actor wouldn't automatically jump again when he touched the ground. I saved and re-opened and it still worked. Sometime later I think some days after, without any known changes to the project, the actor would now triple jump and when space bar was held down it would cause unwanted extra ground jumps. I was very disappointed and discouraged. I was so glad that I had a foundation for platformer gameplay and then suddenly my actor doesn't do what I told it to anymore.
Can someone give me some help? Any advice would be appreciated. You think its a glitch/bug, some kind of update thing? Or, with the info I gave you, might it be that the coding is inherently flawed for what I'm trying to achieve? Thanks alot guys, I know this was long. My future jumping questions will be condensed I promise.
I have some questions about jumping for a platformer game. I looked through the wiki and some templates and found a few useful instructions, and I applied the demonstrated jumping code and with a few tiny tweaks it worked for my game for a while. Then, sometime later, I opened my project and the actor's jumping behaviors weren't the same. I'll try to describe what I did to make it work the first time, and then after I'll describe what changed. I can't figure out what caused the change.
First I created a game.attribute integer called Jump
I created jumping rule for my actor when receive key space bar, and attribute game.jump <2
change attribute to self.motion.linear.velocityY to 650
change attribute game.jump to game.jump+1 (this was to allow a double jump)
Then I created a rule to stop my actor from jumping when touching the ground if the space bar was held down. (I wanted the actor to only be able to jump again if the space bar was first released)
Rule: When actor overlaps or collides with Solid Platform
Constrain attribute game.jump to -1 (To stop the actor from continuing to jump when space bar was held down)
At first when I previewed this code it worked very well. My actor had a double jump and if the space bar was held down the actor wouldn't automatically jump again when he touched the ground. I saved and re-opened and it still worked. Sometime later I think some days after, without any known changes to the project, the actor would now triple jump and when space bar was held down it would cause unwanted extra ground jumps. I was very disappointed and discouraged. I was so glad that I had a foundation for platformer gameplay and then suddenly my actor doesn't do what I told it to anymore.
Can someone give me some help? Any advice would be appreciated. You think its a glitch/bug, some kind of update thing? Or, with the info I gave you, might it be that the coding is inherently flawed for what I'm trying to achieve? Thanks alot guys, I know this was long. My future jumping questions will be condensed I promise.
Comments
- Alex
_________________________________________________________________________________
PDL Productions
Vertical/Horizontal Level Select Template
Mac Mini For SALE!!!
For double jump applied to what I described above, do not change the jump is possible value to false, instead, change the player touched screen bool to false. Then, you can check if motion linear Y isn't = 0, but a more safe way would be to have yet another bool, which you use to know if the player is jumping.
So, when player jumps, set motion linear Y to a value of choice, set the bool "jump pressed" to false, and set the new created bool "player is jumping" to true.
Now, in another rule, if player is jumping true and jump pressed true, than change motion linear Y (again, for the strength of another jump), and change player is jumping to false.
Hope everything is understandable xD English is not my main language so I end up with walls of text everytime I try to explain something, lol