How to make own gravity in Godot 3D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 20xxdd20

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.

:bust_in_silhouette: Reply From: lewis glasgow
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