bonkjj st!
This commit is contained in:
parent
dd66cc2a84
commit
7d20cb9bcc
4 changed files with 38 additions and 6 deletions
|
|
@ -3,17 +3,18 @@ extends CharacterBody2D
|
|||
|
||||
|
||||
@export var walk_speed: float
|
||||
@export var stun_factor: float
|
||||
|
||||
@export_group("Internal References")
|
||||
@export var _animations: AnimationPlayer
|
||||
|
||||
|
||||
var is_stunned := false
|
||||
var stun_time: float = 0.0
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_stunned:
|
||||
pass
|
||||
if stun_time > 0.0:
|
||||
stun_time -= delta
|
||||
else:
|
||||
var input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
|
||||
velocity = input_dir * walk_speed
|
||||
|
|
@ -23,3 +24,15 @@ func _physics_process(delta: float) -> void:
|
|||
_animations.play(&"walk")
|
||||
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func knock(force: Vector2) -> void:
|
||||
velocity = force
|
||||
stun_time = force.length() / stun_factor
|
||||
|
||||
|
||||
#func _on_hurtbox_body_entered(body: Node2D) -> void:
|
||||
#if body is Groove:
|
||||
#var dir = body.global_position.direction_to(global_position)
|
||||
#velocity = dir * body.velocity.length()
|
||||
#stun_time = 0.5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue