Merge branch 'main' of https://github.com/MarcEricMartel/FirstPersonSlapper
This commit is contained in:
commit
9c53b474d4
15
Player.gd
15
Player.gd
@ -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()):
|
||||
|
Loading…
Reference in New Issue
Block a user