Improved dash skill

This commit is contained in:
2024-02-18 18:30:52 +01:00
parent 4c518e93c9
commit 3b2d8514a3
7 changed files with 53 additions and 11 deletions

View File

@ -4,11 +4,13 @@ extends Node
var state: StateComponent
var animation: AnimationComponent
var voice: VoiceComponent
var movement: MovementComponent
func _enter_tree():
state = get_parent().get_node("State") as StateComponent
animation = get_parent().get_node("Animation") as AnimationComponent
voice = get_parent().get_node("Voice") as VoiceComponent
movement = get_parent().get_node("Movement") as MovementComponent
state.current = StateComponent.State.Skill
func end():

View File

@ -1,6 +1,27 @@
extends SkillInstance
var direction: Vector3
func _ready():
animation.play("human/roll")
await get_tree().create_timer(1.0).timeout
direction = movement.direction
if direction == Vector3.ZERO:
direction = (get_parent() as CharacterBody3D).global_basis.z
movement.set_physics_process(false)
set_physics_process(true)
animation.play("human/dash")
await get_tree().create_timer(0.3).timeout
movement.set_physics_process(true)
set_physics_process(false)
end()
func _physics_process(_delta):
if movement.direction:
direction = movement.direction
var body := get_parent() as CharacterBody3D
body.velocity.x = direction.x * movement.move_speed * 3.0
body.velocity.y = 0
body.velocity.z = direction.z * movement.move_speed * 3.0
body.move_and_slide()