ar gravity = 9.8
var location = Vector3()
var capncrunch = Vector3()
export var speed = 7
export var jump_height = 9
var velocity = Vector3()
func getinput():
velocity = Vector3()
if Input.isactionpressed('uiright'):
velocity.x += 1
if Input.isactionpressed('uileft'):
velocity.x -= 1
if Input.isactionpressed("uiforward"):
velocity.z -= 1
if Input.isactionpressed("ui_backwards"):
velocity.z += 1
velocity = velocity.normalized() * speed
func physicsprocess(delta):
getinput()
velocity = moveandslide(velocity)
moveandslide(globaltransform.basis.xform(capncrunch), Vector3.UP)
if Input.is_action_just_pressed("jump"):
if is_on_floor():
capncrunch.y = jump_height
if not is_on_floor():
capncrunch.y -= gravity * delta