summaryrefslogtreecommitdiffstats
path: root/character
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-09-15 03:00:56 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-09-15 03:00:56 -0400
commit764f4d2787418f760e20546ab7abfa07718988e9 (patch)
tree67ad0ad0fb5659456511aad79df6f4a1b5141c8e /character
parent6d57330a9bc8e7da51023208484c8c0bb6842c37 (diff)
downloadgodot_wildjam_49-764f4d2787418f760e20546ab7abfa07718988e9.tar.gz
godot_wildjam_49-764f4d2787418f760e20546ab7abfa07718988e9.zip
convert tabs to spaces
Diffstat (limited to 'character')
-rw-r--r--character/fps_controller/fps_controller.gd126
1 files changed, 63 insertions, 63 deletions
diff --git a/character/fps_controller/fps_controller.gd b/character/fps_controller/fps_controller.gd
index 09ef556..c6c3dc7 100644
--- a/character/fps_controller/fps_controller.gd
+++ b/character/fps_controller/fps_controller.gd
@@ -15,83 +15,83 @@ var velocity : Vector3
var is_climbing : bool = false
func _ready():
- Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
-
+ Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+
func _process(_delta):
- get_input()
-
+ get_input()
+
func _physics_process(_delta):
- handle_movement()
- handle_jumping()
- handle_collision()
-
+ 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:
- dir += global_transform.basis.y
- if Input.is_action_pressed("backward"):
- dir += global_transform.basis.z
- if is_climbing:
- dir += -global_transform.basis.y
- if Input.is_action_pressed("left"):
- 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)
+ var dir : Vector3 = Vector3.ZERO
+
+ #Get base movement input
+
+ if Input.is_action_pressed("forward"):
+ dir += -global_transform.basis.z
+ if is_climbing:
+ dir += global_transform.basis.y
+ if Input.is_action_pressed("backward"):
+ dir += global_transform.basis.z
+ if is_climbing:
+ dir += -global_transform.basis.y
+ if Input.is_action_pressed("left"):
+ 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)
func handle_movement():
- #Apply gravity
- if !is_climbing:
- velocity.y += gravity
- if velocity.y < term_velocity:
- velocity.y = term_velocity
-
- velocity = move_and_slide(velocity, Vector3.UP, true, 4, PI/4, false)
+ #Apply gravity
+ if !is_climbing:
+ 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):
- #Handle mouse movement for camera
- if event is InputEventMouseMotion:
- self.rotate_y(-event.relative.x * Settings.mouse_sens)
- camera.rotate_x(-event.relative.y * Settings.mouse_sens)
- camera.rotation.x = clamp(camera.rotation.x, -1.2, 1.2)
+ #Handle mouse movement for camera
+ if event is InputEventMouseMotion:
+ self.rotate_y(-event.relative.x * Settings.mouse_sens)
+ camera.rotate_x(-event.relative.y * Settings.mouse_sens)
+ camera.rotation.x = clamp(camera.rotation.x, -1.2, 1.2)
func handle_jumping():
- if Input.is_action_just_pressed("jump") and is_on_floor():
- velocity.y = jump_strength
+ 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)
- var collider = collision.collider
- if (collider.get_class() == "RigidBody"):
- var col_force_vec = -collision.normal * inertia # rotate the force along collision normal
- # collision pos
- # > RigidBody.add_force(force, pos) > The position uses the rotation of the global coordinate system, but is centered at the object's origin.
- # > KinematicCollision.position() > The point of collision, in global coordinates.
- # So to add force at collision position, substract colliders pos from collision.position
- var col_pos = collision.position - collider.transform.origin
- collider.add_force(col_force_vec, col_pos)
+ for index in get_slide_count():
+ var collision = get_slide_collision(index)
+ var collider = collision.collider
+ if (collider.get_class() == "RigidBody"):
+ var col_force_vec = -collision.normal * inertia # rotate the force along collision normal
+ # collision pos
+ # > RigidBody.add_force(force, pos) > The position uses the rotation of the global coordinate system, but is centered at the object's origin.
+ # > KinematicCollision.position() > The point of collision, in global coordinates.
+ # So to add force at collision position, substract colliders pos from collision.position
+ var col_pos = collision.position - collider.transform.origin
+ collider.add_force(col_force_vec, col_pos)
func _on_ladder_detector_body_entered(body):
- if body.is_in_group("ladder"):
- is_climbing = true
+ if body.is_in_group("ladder"):
+ is_climbing = true
func _on_ladder_detector_body_exited(body):
- if body.is_in_group("ladder"):
- is_climbing = false
+ if body.is_in_group("ladder"):
+ is_climbing = false