Hi, semi-new to the BGE here,
I’ve made a simple movement script for my Dynamic character (a cube) and am having an issue when I run into a wall or anything where the character gets pushed around. I don’t want to set the physics type to Character because you can’t jump with that. Anyone have a solution? It would be much appreciated. Here’s what I have at the moment:
import GameLogic
cont = GameLogic.getCurrentController()
player = cont.owner
default_speed = 0.15
jump_force = 8000
x = 0
y = 0
if cont.sensors["Forward"].positive:
y = default_speed
if cont.sensors["Backward"].positive:
y = -default_speed
if cont.sensors["Left"].positive:
x = -default_speed
if cont.sensors["Right"].positive:
x = default_speed
if cont.sensors["Jump"].positive and cont.sensors["OnGround"].positive:
player.applyForce([0.0,0.0,jump_force],False)
if cont.sensors["Sprint"].positive and cont.sensors["OnGround"].positive:
y *= 1.5
player.applyMovement([x,y,0.0],True)