hello my character is physics type character and i wanna use the jump of character motion
I can’t find a way to use jump with python
gameMoveandJump.blend (511.0 KB)
hello my character is physics type character and i wanna use the jump of character motion
I can’t find a way to use jump with python
gameMoveandJump.blend (511.0 KB)
If this is UPBGE 0.2.5 or higher,
You can delete the character motion-brick and call it directly this way.
import bge
cont = bge.logic.getCurrentController()
obj = cont.owner
keyboard = bge.logic.keyboard
if keyboard.inputs[bge.events.SPACEKEY].activated:
bge.constraints.getCharacter(obj).jump()
Thanks bro it worked for me
Cool, so you are on UPBGE 0.2.5.
here is all in one script :
import bge
from mathutils import Vector
cont = bge.logic.getCurrentController()
own = cont.owner
keyboard = bge.logic.keyboard.inputs
speed = 0.1
runSpeed = speed*2.0
ws = keyboard[bge.events.WKEY].active-keyboard[bge.events.SKEY].active
ad = keyboard[bge.events.DKEY].active-keyboard[bge.events.AKEY].active
move_vec = Vector([ad,ws,0]).normalized()
if keyboard[bge.events.LEFTSHIFTKEY].active: move_vec *= runSpeed
else: move_vec *= speed
#Jump
if keyboard[bge.events.SPACEKEY].activated: bge.constraints.getCharacter(own).jump()
#Character Movement
onGround = bge.constraints.getCharacter(own).onGround
if onGround: bge.constraints.getCharacter(own).walkDirection = own.worldOrientation * move_vec
### to make changing movement during jump possible use:
#bge.constraints.getCharacter(own).walkDirection = own.worldOrientation * move_vec
025_gameMoveandJump.blend (503.1 KB)