summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--character/fps_controller/fps_controller.gd15
1 files changed, 4 insertions, 11 deletions
diff --git a/character/fps_controller/fps_controller.gd b/character/fps_controller/fps_controller.gd
index c6c3dc7..bc737f5 100644
--- a/character/fps_controller/fps_controller.gd
+++ b/character/fps_controller/fps_controller.gd
@@ -16,20 +16,18 @@ var is_climbing : bool = false
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
-
+
func _process(_delta):
get_input()
-
+
func _physics_process(_delta):
handle_movement()
handle_jumping()
handle_collision()
-
+
func get_input():
var dir : Vector3 = Vector3.ZERO
-
#Get base movement input
-
if Input.is_action_pressed("forward"):
dir += -global_transform.basis.z
if is_climbing:
@@ -42,14 +40,11 @@ func get_input():
dir += -global_transform.basis.x
if Input.is_action_pressed("right"):
dir += global_transform.basis.x
-
dir = dir.normalized()
-
#Pull X and Z values from directional input. Velocity.y will be handled in physics loop unless climbing.
if is_climbing:
velocity.y = lerp(velocity.y, dir.y * walk_speed, accel)
-
velocity.x = lerp(velocity.x, dir.x * walk_speed, accel)
velocity.z = lerp(velocity.z, dir.z * walk_speed, accel)
@@ -59,7 +54,6 @@ func handle_movement():
velocity.y += gravity
if velocity.y < term_velocity:
velocity.y = term_velocity
-
velocity = move_and_slide(velocity, Vector3.UP, true, 4, PI/4, false)
func _input(event):
@@ -72,7 +66,6 @@ func _input(event):
func handle_jumping():
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jump_strength
-
func handle_collision():
for index in get_slide_count():
var collision = get_slide_collision(index)
@@ -94,4 +87,4 @@ func _on_ladder_detector_body_entered(body):
func _on_ladder_detector_body_exited(body):
if body.is_in_group("ladder"):
- is_climbing = false
+ is_climbing = false \ No newline at end of file