Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | FiredReadyBlocks |
Whenever my player character lands on the floor, they cannot move. (is_on_floor always comes back false for some reason) Heres my player’s script:
extends KinematicBody
#Initializes Variables
var velocity = Vector3(0,0,0)
const speed = 1
var acc = 1
var gravity = 0.01
#Handels Player Physics
func _physics_process(delta):
velocity.y -= gravity
if Input.is_key_pressed(KEY_D) and Input.is_key_pressed(KEY_A):
velocity.x = lerp(velocity.x, 0, 0.1)
elif Input.is_key_pressed(KEY_D):
velocity.x = min(velocity.x + acc, speed)
elif Input.is_key_pressed(KEY_A):
velocity.x = max(velocity.x + -acc, -speed)
else:
velocity.x = lerp(velocity.x, 0, 0.1)
move_and_slide(velocity, Vector3.UP)
Any Ideas?