Is it possible to make an object jump and then double jump along with animations that could be played with actuators?
For example:
The player presses the spacebar, and jumps. But if it is pressed too fast, the player does not double jump. You need to be at the top of your jump or a little less to double jump. In water the player is able to jump, but less, and is unable to do a double jump.
This would be python code. Jumping can be turned off by setting the jump_count property to -1.
TL;TR
- If you don’t mind using Character physics, there is already a easy technique setup for this.
Properties Editor - Physics Tab
Logic Brick Setup
Script
import bge
def main(self):
if self.owner["activeJumping"] == False:
# IDLE
if bge.constraints.getCharacter(self.owner).jumpCount == 0:
print(bge.constraints.getCharacter(self.owner).jumpCount)
self.owner["activeJumping"] = True
print(self.owner["activeJumping"])
# FIRST JUMP
elif bge.constraints.getCharacter(self.owner).jumpCount == 1:
print(bge.constraints.getCharacter(self.owner).jumpCount)
self.owner["activeJumping"] = True
print(self.owner["activeJumping"])
# SECOND JUMP
elif bge.constraints.getCharacter(self.owner).jumpCount == 2:
print(bge.constraints.getCharacter(self.owner).jumpCount)
self.owner["activeJumping"] = True
print(self.owner["activeJumping"])
Summary
- Each jump count (0 or not) should only register once, allowing the playing of 1 animation instead of an infinite loop of them.
Blend
UPBGE_03_x2_Jump_w_Anim.blend (111.4 KB)
How can I also make a jumping system like this for non-character specific objects? With Dynamic/Rigid Body objects, you can measure speed accurately via the linearVelocity module, so how can I do this?
Trying to do a jump counter via an integer property and true pulse sensor and also a Keyboard sensor causes the integer property to shoot up into the sky.
what about coming with questions with links to the documentation you don’t get ?
i know it’s more easy to ask, but if you have a look at the documentation, beside the fact you will find your own answers , you will find stuff that would give you ideas and even improve your current solutions .