rudimentary clamber

This commit is contained in:
derek
2025-06-17 10:32:31 -05:00
parent 7c76c791f2
commit 4047a1c9a8
13 changed files with 98 additions and 16 deletions

View File

@@ -15,7 +15,12 @@ func standard_movement(delta):
character.velocity.z = lerp(character.velocity.z, character.movement_input().z * move_speed * character.speed_modifiers(),delta * move_transition_speed)
func standard_jump():
return character.JUMP_VELOCITY * character.speed_modifiers()
#first check for clamber, otherwise jump
print("CAN CLAMBER? - ",character.can_clamber())
if character.can_clamber():
Transitioned.emit(self,"clamber")
else:
character.velocity.y += character.JUMP_VELOCITY * character.speed_modifiers()
func apply_gravity(delta):
character.velocity.y -= 9.8 * 1.25 * delta

View File

@@ -65,6 +65,9 @@ var wall_run_direction
# Ladder
var current_ladder
# Clamber
var clamber_point
## GUNS AND AMMO
var gun : Node
var holstered_gun_id : int
@@ -136,6 +139,9 @@ var controlled_elsewhere = false
@onready var weapon_select_menu: Control = $Head/Recoil/Camera3D/WeaponSelect
@onready var wall_jump_timer: Timer = $WallJumpTimer
@onready var remaining_stamina : float = level_control.gamemode.max_stamina
@onready var clamber_max_ray: RayCast3D = $ClamberMaxRay
@onready var clamber_check_ray: RayCast3D = $ClamberCheckRay
@onready var clamber_point_ray: RayCast3D = $ClamberPointRay
func _ready():
level_control.player = self
@@ -385,6 +391,31 @@ func speed_modifiers():
return speed_multiplier
func can_clamber():
var clamber_ray_collided = false
const CHECK_RESOLUTION = .1
const MAX_RAY_POSITION = .607
const MIN_RAY_POSITION = -.9
while clamber_check_ray.position.y > MIN_RAY_POSITION:
if clamber_check_ray.is_colliding():
clamber_ray_collided = true
break
clamber_check_ray.position.y -= CHECK_RESOLUTION
clamber_check_ray.position.y = MAX_RAY_POSITION
if clamber_ray_collided and !clamber_max_ray.is_colliding():
return true
else:
return false
func get_clamber_point():
if clamber_point_ray.is_colliding():
return clamber_point_ray.get_collision_point()
else:
return clamber_point_ray.global_position
func joypad_walk():
# Joypad right stick look control
var dir_out = Vector2(0,0)

18
scripts/player_clamber.gd Normal file
View File

@@ -0,0 +1,18 @@
extends PlayerState
class_name PlayerClamber
var clamber_point
func Enter():
clamber_point = character.get_clamber_point()
character.standing_collision.disabled = true
character.crouching_collision.disabled = true
func Physics_Update(delta):
character.velocity = Vector3.ZERO
character.global_position = clamber_point + Vector3(0,1,0)
Transitioned.emit(self,"on foot")
func Exit():
character.standing_collision.disabled = false
character.crouching_collision.disabled = false

View File

@@ -0,0 +1 @@
uid://cl8wpx8g1b5ce

View File

@@ -17,8 +17,8 @@ func Update(delta):
func Physics_Update(delta):
if character.is_on_floor():
standard_movement(delta)
else:
Transitioned.emit(self,"in air")
apply_gravity(delta)
if Input.is_action_just_pressed("crouch"):
if !character.crouch_check.is_colliding():
@@ -32,7 +32,7 @@ func Physics_Update(delta):
if Input.is_action_just_pressed("jump"):
if !character.crouch_check.is_colliding():
character.recoil.add_recoil(Vector3(-.2,.03,.03),5,10)
character.velocity.y += character.JUMP_VELOCITY
standard_jump()
transition_out_of_crouch()

View File

@@ -18,9 +18,9 @@ func Physics_Update(delta):
enable_wall_rays()
if Input.is_action_just_pressed("jump") and character.jumps_remaining > 0:
if Input.is_action_just_pressed("jump") and (character.jumps_remaining > 0 or character.can_clamber()):
character.jumps_remaining -= 1
character.velocity.y += character.JUMP_VELOCITY
standard_jump()
if Input.is_action_just_pressed("sprint") and air_dash_left > 0:
air_dash_left -= 1

View File

@@ -16,4 +16,4 @@ func Physics_Update(delta):
if Input.is_action_just_pressed("jump"):
character.jumps_remaining -= 1
character.velocity.y += standard_jump()
standard_jump()

View File

@@ -1,11 +1,22 @@
extends PlayerState
class_name PlayerOnLadder
var climbing_started = false
func Enter():
climbing_started = false
func Physics_Update(delta):
character.global_position.x = lerp(character.global_position.x,character.current_ladder.global_position.x,delta * 8)
character.global_position.z = lerp(character.global_position.z,character.current_ladder.global_position.z,delta * 8)
ladder_movement(delta)
if !character.is_on_floor() and !climbing_started:
climbing_started = true
if character.is_on_floor() and climbing_started:
Transitioned.emit(self, "on foot")
func ladder_movement(delta):
var direction = Input.get_vector("move_down","move_up","move_left","move_right").x

View File

@@ -16,7 +16,7 @@ func Physics_Update(delta):
Transitioned.emit(self,"in air")
func wall_jump():
character.velocity += (Vector3(0,1,0) + character.wall_run_direction).normalized() * 15
character.velocity += (Vector3(0,1,0) + character.wall_run_direction).normalized() * 15 * character.speed_modifiers()
Transitioned.emit(self,"in air")
func wall_run_movement(delta):
@@ -27,4 +27,4 @@ func wall_run_movement(delta):
Transitioned.emit(self,"in air")
func wall_run_gravity(delta):
character.velocity.y -= 9.8 * .75 * delta
character.velocity.y -= 9.8 * delta