added wall running
This commit is contained in:
21
scripts/player_wall_running.gd
Normal file
21
scripts/player_wall_running.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends PlayerState
|
||||
class_name PlayerWallRunning
|
||||
|
||||
func Physics_Update(delta):
|
||||
if character.is_on_floor():
|
||||
Transitioned.emit(self,"on foot")
|
||||
else:
|
||||
wall_run_movement(delta)
|
||||
|
||||
apply_gravity(delta)
|
||||
|
||||
if !can_wall_run():
|
||||
Transitioned.emit(self,"in air")
|
||||
|
||||
func wall_jump():
|
||||
character.velocity += (Vector3(0,1,0) + character.wall_run_surface_normal).normalized() * 10
|
||||
|
||||
func wall_run_movement(delta):
|
||||
if Input.is_action_pressed("move_up"):
|
||||
character.velocity.x = lerp(character.velocity.x,character.wall_run_direction.x * move_speed,delta * 7)
|
||||
character.velocity.z = lerp(character.velocity.z,character.wall_run_direction.z * move_speed,delta * 7)
|
||||
Reference in New Issue
Block a user