playing with physical ledge grab
This commit is contained in:
@@ -17,15 +17,23 @@ func standard_movement(delta):
|
||||
func jump_with_weight_mod():
|
||||
character.velocity.y += character.JUMP_VELOCITY * character.speed_modifiers()
|
||||
|
||||
func ledge_grab():
|
||||
if Input.is_action_pressed("interact"):
|
||||
character.ledge_collision.disabled = false
|
||||
else:
|
||||
character.ledge_collision.disabled = true
|
||||
|
||||
func is_grabbing_ledge():
|
||||
if character.ledge_collision.disabled == false:
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func standard_jump():
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
#first check for clamber, otherwise jump
|
||||
if character.can_clamber():
|
||||
Transitioned.emit(self,"ledge grab")
|
||||
else:
|
||||
if character.jumps_remaining > 0:
|
||||
character.jumps_remaining -= 1
|
||||
jump_with_weight_mod()
|
||||
if character.jumps_remaining > 0:
|
||||
character.jumps_remaining -= 1
|
||||
jump_with_weight_mod()
|
||||
|
||||
func apply_gravity(delta):
|
||||
character.velocity.y -= 9.8 * 1.25 * delta
|
||||
|
||||
@@ -144,6 +144,8 @@ var controlled_elsewhere = false
|
||||
@onready var clamber_point_ray: RayCast3D = $ClamberPointRay
|
||||
@onready var ledge_l_ray: RayCast3D = $LedgeLRay
|
||||
@onready var ledge_r_ray: RayCast3D = $LedgeRRay
|
||||
@onready var ledge_collision: CollisionShape3D = $LedgeCollision
|
||||
|
||||
|
||||
func _ready():
|
||||
level_control.player = self
|
||||
|
||||
@@ -13,14 +13,9 @@ func Physics_Update(delta):
|
||||
standard_movement(delta)
|
||||
apply_gravity(delta)
|
||||
|
||||
standard_jump()
|
||||
|
||||
if character.is_on_floor():
|
||||
if character.is_on_floor() and !is_grabbing_ledge():
|
||||
Transitioned.emit(self,"on foot")
|
||||
|
||||
enable_wall_rays()
|
||||
|
||||
|
||||
if Input.is_action_just_pressed("sprint") and air_dash_left > 0:
|
||||
air_dash_left -= 1
|
||||
character.velocity += character.movement_input().normalized() * air_dash_amount
|
||||
@@ -28,5 +23,13 @@ func Physics_Update(delta):
|
||||
if Input.is_action_just_pressed("crouch"):
|
||||
Transitioned.emit(self,"ground pound")
|
||||
|
||||
enable_wall_rays()
|
||||
|
||||
if can_wall_run():
|
||||
start_wall_running()
|
||||
|
||||
standard_jump()
|
||||
ledge_grab()
|
||||
|
||||
func Exit():
|
||||
character.ledge_collision.disabled = true
|
||||
|
||||
Reference in New Issue
Block a user