Im want to make a 3D FPS game in Godot 3.4.4 and i have problems with jumping my code ↓↓↓
extends KinematicBody
export var speed = 11
export var accel = 5
export var gravity = 0.98
export var jump_power = 30
onready var head = $Head
onready var camera = $Head/Camera
var velocity = Vector3()
func _physics_process(delta):
var head_basis = head.get_global_transform().basis
var direction = Vector3()
if Input.is_action_pressed("ui_up"):
direction -= head_basis.z
elif Input.is_action_pressed("ui_down"):
direction += head_basis.z
if Input.is_action_pressed("ui_left"):
direction -= head_basis.x
elif Input.is_action_pressed("ui_right"):
direction += head_basis.x
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y += jump_power
direction = direction.normalized()
velocity = velocity.linear_interpolate(direction * speed, accel * delta)
velocity.y -= gravity
velocity = move_and_slide(velocity)
if me printing is on floor()
and im reciving false, why?
P.S.:I always write velocity.y - = gravity because I read other answers and it said: "You always need to move the player a little down"