The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

i am following garbaj third person controller and is on floor is 80% returns false and randomly returns true when on ground. i checked everyhting i watched the video 5 times. nothing works. help.

example of debug:

(0, -70.904762, 0)False
(0, -70.904762, 0)True
(0, -71.068092, 0)False
(0, -71.231422, 0)False

    extends KinematicBody

onready var gun_pivot: Spatial = $GunPivot
onready var pivot: Spatial = $Pivot

export var gravity = .98
export var jump = 5 
var capncrunch = Vector3()

var direction = Vector3()
var speed = 10
var velocity = Vector3()
var acceleration = 5

var mouse_sensitivity = .1

func _ready() -> void:

func _input(event: InputEvent) -> void:

    if Input.is_action_just_pressed('ui_cancel'):
    if Input.is_action_just_pressed('shoot'):

    if event is InputEventMouseMotion:
        rotate_y(deg2rad(-event.relative.x * mouse_sensitivity))
        pivot.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
        pivot.rotation.x = clamp(pivot.rotation.x, deg2rad(-90), deg2rad(90))
        gun_pivot.rotate_x(deg2rad(-event.relative.y * mouse_sensitivity))
        gun_pivot.rotation.x = clamp(pivot.rotation.x, deg2rad(-90), deg2rad(90))

func _process(delta: float) -> void:

    direction = Vector3()

    if Input.is_action_pressed('move_forward'):

        direction -= transform.basis.z

    elif Input.is_action_pressed('move_backwards'):

        direction += transform.basis.z

    if Input.is_action_pressed('move_left'):

        direction -= transform.basis.x

    elif Input.is_action_pressed('move_right'):

        direction += transform.basis.x

    print(capncrunch ,is_on_floor())
    move_and_slide(capncrunch, Vector3.UP)

    direction = direction.normalized()
    velocity = direction * speed
    velocity.linear_interpolate(velocity, acceleration * delta)
    move_and_slide(velocity, Vector3.UP)

func apply_gravity(delta):
    if not is_on_floor():
        capncrunch.y -= gravity * delta

func jump():
    if Input.is_action_just_pressed('jump') and is_on_floor():
        capncrunch.y = jump
Godot version 3.5 mono and i tested this with 3.5.1 and 3.5 standard
in Engine by (12 points)

1 Answer

+1 vote

This is a known issue. The best way to work around this is to store the result of is_on_floor() over 3 frames in an Array, then write a function that returns true if any of the values in the Array are true.

See Shifty's Godot Character Movement Manifesto for more information.

by (12,878 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.