So I'm relatively new to Godot, and I just tried making my first 2.5D game. I want to implement gravity, but the "isonfloor" function is always reporting false, so the player never stops falling. (It just falls through the floor) Both the player and the Floor have collision. I've been messing with this for several hours now! Here's my player script:
extends KinematicBody
var velocity = Vector3(0,0,0)
var SPEED = 1
var accel = 0.1
var gravity = 0.1
var jump = 0
func physicsprocess(delta):
if not isonfloor():
velocity.y -= gravity
print(isonfloor())
if Input.iskeypressed(KEYD) and Input.iskeypressed(KEYA):
velocity.x = 0
elif Input.iskeypressed(KEYD):
velocity.x = min(velocity.x + accel, SPEED)
elif Input.iskeypressed(KEYA):
velocity.x = max(velocity.x - accel, -SPEED)
else:
velocity.x = lerp(velocity.x, 0, 0.1)
if Input.is_key_pressed(KEY_W) and Input.is_key_pressed(KEY_S):
pass
elif Input.is_key_pressed(KEY_S):
pass
elif Input.is_key_pressed(KEY_W):
pass
else:
pass
#velocity.z = lerp(velocity.z, 0, 0.1)
if not Input.is_key_pressed(KEY_W) and not Input.is_key_pressed(KEY_A) and not Input.is_key_pressed(KEY_S) and not Input.is_key_pressed(KEY_D):
pass
move_and_slide(velocity)
btw, I haven't used the jump variable yet. Cant jump it you just fall through the floor!!! If someone can understand what the problem is or needs further info, please reply! Any help is much appreciated! Have a nice day.
-Fired