gravity increases with time

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

Hi guys
sorry for my bad English ":slight_smile:
I’m new in godot
I was try to make first person control
It’s been 2 week new and I did some good work
And I’ve been struggling lately with not making the player jump smoothly
And I discovered that the gravity increases with time
I don’t know how to stop this
I can’t find sources in my language to search
if you can help me I will be thankful


it’s 3D node

Please don’t use images to show code, as this is not accessible (text can’t be selected and copied). Use indented code blocks instead.

Calinou | 2022-08-08 11:26

sorry

extends KinematicBody
#physics
export var walk_speed : float = 5.0
export var Jump : float = 10.0
export var gravity : float = 9.8
export var wight : float = 10
var vel = Vector3.ZERO

#look stats
export var mouse_speed : float = 1.0
onready var Head = $Head


func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _input(event):
	if event is InputEventMouseMotion:
		Head.rotate_x(deg2rad(-event.relative.y * mouse_speed))
		rotate_y(deg2rad(-event.relative.x * mouse_speed))
	Head.rotation_degrees.x = clamp(Head.rotation_degrees.x, -55, 55)

func _physics_process(delta):
	var input = Vector3.ZERO
	var _Basis = Head.global_transform.basis
	
	
	if Input.is_action_pressed("Forwards"):
		input -= _Basis.z
	if Input.is_action_pressed("Bsckwards"):
		input += _Basis.z
	if Input.is_action_pressed("Left"):
		input -= _Basis.x
	if Input.is_action_pressed("Right"):
		input += _Basis.x
		
	input = input.normalized()
	vel = vel.linear_interpolate(input * walk_speed , wight * delta)
	
	if not is_on_floor():
		vel.y -= gravity
		print(vel.y)
	if Input.is_action_just_pressed("Jump") and is_on_floor():
		vel.y = Jump
	
	vel = move_and_slide(vel, Vector3.UP)

ali1995 | 2022-08-08 13:11

when I put delta with my gravity it’s feel more smoothly now

ali1995 | 2022-08-09 15:19