Jumping While in Air/Falling

elhennon

  • Posts: 13
Hello. I am working on a game where the main actor and platforms are falling, and the actor must reach the top by jumping on the platforms. As I am testing the game, I have found it would be better if the actor can jump while on the platforms, as well as when they are falling. However, the code I thought would produce this result is not working, and the actor can only jump while on the platforms. Is there a way I can make the actor also jump while falling? Hope this question makes sense, and I appreciate the help. Thank you!

dreph

  • Posts: 142
Ok, so I had to look at the code a few times, but I think I know where you need to start.

First off, you have a Touch Floor attribute.  You need to make sure that this attribute is being triggered back and forth appropriately.  With that said, you need to make sure that the platforms are in the appropriate groups and not just "Actor" which is default.  Check your Actors for the platforms and make sure they are in the Falling/Unmoveable Platform groups respectively.

Secondly, you have two places that involve "action1".  One of them is an input trigger, and one of them is under "when updating" for input.   You only need one of those in action to initiate the action. 

Finally, during your "when updating" portion, you have a spot that automatically sets the y-speed in a downward direction if "Touch Floor" is false.  Depending on how your logic is going to be finalized, you may want to rework how falling works and utilize gravity and pushing the director.  Hope this helps.

elhennon

  • Posts: 13
So, I ended up omitting the touch floor attribute entirely to try and simplify the code. Instead, I am using a boolean to test if the player has already jumped (to prevent continuous jumping that allows the player to reach the top almost immediately). It works the first time (there is a delay between jumps). Then it allows the player to jump continuously, basically flying. Do you have any suggestions on how to prevent this? Again, I really appreciate the help!! Thank you.

dreph

  • Posts: 142
Sorry for the delay, but it is because you are setting the y-speed of the actor instead of pushing the actor or setting velocity.  Therefore, when the actor jumps, they never stop jumping because nothing in your code stops the actor from "Set y-speed"

If you use push actor or set velocity, that alleviates this and utilizes gravity.