0 votes

I've been trying to make a gravity similar to this one

I want to replicate so the player can go up on any slopes (even 1 degree slopes) but without the player thrown up in the sky.

Godot version 3.3.2
in Engine by (53 points)

1 Answer

0 votes
extends KinematicBody

var grav = 0
var vel = Vector3.ZERO

export var grav_strength = 0.4
export var jump_height = 10

func _process(delta):
    vel = Vector3.ZERO
    if is_on_floor():
        grav = 0
        vel.y = -grav_strength
        grav += grav_strength

    if Input.is_action_just_pressed("jump") and is_on_floor():
        vel.y = 0
        grav = -jump_height

    vel.y -= grav
by (256 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 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.