I’ve tried to use this physics setting multiple times, and it’s always given me problems, so perhaps I’m using it wrong? I was wondering if someone who knows how to use it properly can help me out with this.
So my first issue is trying to implement a jump. The actual movement upwards of the jump works fine, its when you try to use any other movement in the air. Once you try to move in any other direction, the player stops falling and instead goes straight forward. Is there a fix for this? I’m using force for the jump and lin vel for the movement.
import bge
cont = bge.logic.getCurrentController()
own = cont.owner
max = 5
if cont.sensors['Forward_Key'].positive:
if own.localLinearVelocity.x< max:
own.applyForce((36,0,0),1)
#push forward
own.localLinearVelocity.y*=.5
#don't slide sideways
elif cont.sensors['Back_Key'].positive:
if own.localLinearVelocity.x> -max:
own.applyForce((-36,0,0),1)
own.localLinearVelocity.y*=.5
else:
own.localLinearVelocity.y*=.5
own.localLinearVelocity.x*=.5
#slow down
if own.localLinearVelocity.magnitude<.05:
#idle
pass
keyboard sensor or joystick etc named 'Forward_Key'-------------this python
keyboard sensor or joystick etc named 'Back_Key'----------------/
always---------------------------------------------------------/