crouch still needs tweaking on the camera but functional, added air dash
This commit is contained in:
44
scripts/player_crouched.gd
Normal file
44
scripts/player_crouched.gd
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
extends PlayerState
|
||||||
|
class_name PlayerCrouched
|
||||||
|
|
||||||
|
var stand_up = false
|
||||||
|
|
||||||
|
func Enter():
|
||||||
|
character.recoil.add_recoil(Vector3(.2,0,0),5,10)
|
||||||
|
character.crouch_audio.play()
|
||||||
|
character.velocity += character.movement_input() * 20
|
||||||
|
character.standing_collision.disabled = true
|
||||||
|
|
||||||
|
func Update(delta):
|
||||||
|
#move camera down to crouched height
|
||||||
|
if character.head.position != character.CROUCHED_POS:
|
||||||
|
character.head.position = lerp(character.head.position, character.CROUCHED_POS, delta * 8)
|
||||||
|
|
||||||
|
func Physics_Update(delta):
|
||||||
|
if character.is_on_floor():
|
||||||
|
standard_movement(delta)
|
||||||
|
else:
|
||||||
|
Transitioned.emit(self,"in air")
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("crouch"):
|
||||||
|
if !character.crouch_check.is_colliding():
|
||||||
|
character.recoil.add_recoil(Vector3(-.2,.03,.03),5,10)
|
||||||
|
character.crouch_audio.play()
|
||||||
|
transition_out_of_crouch()
|
||||||
|
else:
|
||||||
|
character.recoil.add_recoil(Vector3(-.2,.03,.03),20,10)
|
||||||
|
character.hit_head.play()
|
||||||
|
|
||||||
|
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
|
||||||
|
transition_out_of_crouch()
|
||||||
|
|
||||||
|
|
||||||
|
func transition_out_of_crouch():
|
||||||
|
character.head.position = character.STAND_POS
|
||||||
|
Transitioned.emit(self,"on foot")
|
||||||
|
|
||||||
|
func Exit():
|
||||||
|
character.standing_collision.disabled = false
|
||||||
1
scripts/player_crouched.gd.uid
Normal file
1
scripts/player_crouched.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dlymy0m127nt0
|
||||||
9
scripts/player_falling.gd
Normal file
9
scripts/player_falling.gd
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
extends PlayerState
|
||||||
|
class_name PlayerFalling
|
||||||
|
|
||||||
|
func Physics_Update(delta):
|
||||||
|
if character.is_on_floor():
|
||||||
|
Transitioned.emit(self,"on foot")
|
||||||
|
|
||||||
|
standard_movement(delta)
|
||||||
|
apply_gravity(delta)
|
||||||
1
scripts/player_falling.gd.uid
Normal file
1
scripts/player_falling.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://dac0eeav1jped
|
||||||
25
scripts/player_jumping.gd
Normal file
25
scripts/player_jumping.gd
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
extends PlayerState
|
||||||
|
class_name PlayerJumping
|
||||||
|
|
||||||
|
@export var air_dash_amount = 40.0
|
||||||
|
|
||||||
|
var air_dash_max = 1
|
||||||
|
var air_dash_left
|
||||||
|
|
||||||
|
func Enter():
|
||||||
|
air_dash_left = air_dash_max
|
||||||
|
|
||||||
|
func Physics_Update(delta):
|
||||||
|
standard_movement(delta)
|
||||||
|
apply_gravity(delta)
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("jump") and character.jumps_remaining > 0:
|
||||||
|
character.jumps_remaining -= 1
|
||||||
|
character.velocity.y += character.JUMP_VELOCITY
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if character.is_on_floor():
|
||||||
|
Transitioned.emit(self,"on foot")
|
||||||
1
scripts/player_jumping.gd.uid
Normal file
1
scripts/player_jumping.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://clyi3lxv4xt4g
|
||||||
22
scripts/player_on_foot.gd
Normal file
22
scripts/player_on_foot.gd
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
extends PlayerState
|
||||||
|
class_name PlayerOnFoot
|
||||||
|
|
||||||
|
|
||||||
|
func Enter():
|
||||||
|
character.jumps_remaining = character.MAX_JUMPS
|
||||||
|
|
||||||
|
func Physics_Update(delta):
|
||||||
|
if character.is_on_floor():
|
||||||
|
standard_movement(delta)
|
||||||
|
else:
|
||||||
|
Transitioned.emit(self,"in air")
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("crouch"):
|
||||||
|
if character.is_on_floor():
|
||||||
|
Transitioned.emit(self,"crouched")
|
||||||
|
else:
|
||||||
|
character.velocity.y -= 25
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("jump"):
|
||||||
|
character.jumps_remaining -= 1
|
||||||
|
character.velocity.y += character.JUMP_VELOCITY
|
||||||
1
scripts/player_on_foot.gd.uid
Normal file
1
scripts/player_on_foot.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://o7g6oowyn6pe
|
||||||
Reference in New Issue
Block a user