0 votes

I discovered a problem when I'm standing between on an edge and a wall the gravity increments and I get stuck in there movement controls becomes stiff by the force of the gravity still falling. I waited for the gravity to increment and later destroy the cube. I printed the velocity output on run time.

enter image description here

I made 2 code for the player controls and the obstacle a code to destroy to see the player would fall hard by the immense gravity values still increment.

Code for the Player:

extends KinematicBody

var velocity = Vector3(0,0,0)

export var SPEED : float = 8

const UP = Vector3(0,1,0)

func _physics_process(delta):

var g = Vector3(0,-39.8,0)

velocity += g * delta

if Input.is_action_pressed("right") and Input.is_action_pressed("left"):
    velocity.x = 0
elif Input.is_action_pressed("right"):
    velocity.x = SPEED
elif Input.is_action_pressed("left"):
    velocity.x = -SPEED
    velocity.x = lerp(velocity.x,0,.75)

if Input.is_action_pressed("forward") and Input.is_action_pressed("backward"):
    velocity.z = 0
elif Input.is_action_pressed("backward"):
    velocity.z = SPEED
elif Input.is_action_pressed("forward"):

    velocity.z = -SPEED
    velocity.z = lerp(velocity.z,0,.75)

if is_on_floor():
    if Input.is_action_pressed("jump"):
        velocity.y = 18

velocity = move_and_slide(velocity, UP)


Code for the Obstacle cube:

extends StaticBody

func _process(delta):



hope to find answers for this problem it could be simple.

in Engine by (64 points)

1 Answer

0 votes
  • Add a max_falling_speed:

    velocity.y = min(velocity.y, max_falling_speed)
  • Or only apply gravity if airborne:

    if not is_on_floor():
        velocity += g * delta
  • Or reset the vertical speed if on the ground:

    if is_on_floor():
        velocity.y = 0
by (4,101 points)
  1. I don't want the gravity to have a max falling speed I want it to continually increment
  2. Tried and doesn't work
  3. That's the problem it doesn't tell you it's on floor so the gravity still increment

I got it now. 2 and 3 is from the same problem.

With the first solution, you can still have gradual falling but it just stops accelerating at a set point.
Unless it's a mechanic or something, don't design levels like that. It's just unnecessarily creating problems for yourself.
Alternatively, consider using a cylinder shape.

There's no solution for the capsule? Maybe their capsule collision shape must have some bugs in the engine I assumed. Probably report it to the Godot devs. In the 2D world I did the same thing between a wall and an edge the gravity still falls but it doesn't increment gravity so I don't get any stiff movement controls and I can walk back up to the platform. At some point in the 3D world when I run the game again the problem was supposed to be gone I was able to walk around, movement didn't became stiff and gravity became natural but again I ran the game the problem came back and it's not going away anymore. I want to use a capsule shaped collision so I can walk to edges perhaps my solution with a capsule is I'll avoid placing these kind of obstacles so happening won't come into play.

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 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 webmaster@godotengine.org with your username.