This commit is contained in:
MarcEricMartel 2022-10-11 09:52:03 -04:00
commit 9c53b474d4

View File

@ -2,11 +2,15 @@ extends KinematicBody
export var speed = 20
export var h_acceleration = 6
export var air_acceleration = 1
export var normal_acceleration = 6
export var gravity = 40
export var jump = 30
export var mouse_sensitivity = 0.03
var bottom_boudaries = -20
var full_contact = false
var direction = Vector3()
var h_velocity = Vector3()
@ -28,10 +32,10 @@ func _input(event):
func _physics_process(delta):
if Input.is_action_just_pressed("uncapture_mouse"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
elif Input.is_action_just_released("uncapture_mouse"):
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if global_transform.origin.y < bottom_boudaries:
global_transform.origin.x = 0
global_transform.origin.y = 10
global_transform.origin.z = 0
direction = Vector3()
@ -39,10 +43,13 @@ func _physics_process(delta):
if not is_on_floor():
gravity_vec += Vector3.DOWN * gravity * delta
h_acceleration = air_acceleration
elif is_on_floor() and full_contact:
gravity_vec = -get_floor_normal() * gravity
h_acceleration = normal_acceleration
else:
gravity_vec = -get_floor_normal()
h_acceleration = normal_acceleration
if Input.is_action_just_pressed("jump") and (is_on_floor() or ground_check.is_colliding()):