From 3d558ca28d82b78f0602e9c8f51a24f3bb769348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Mart=C3=ADnez=20Palacio?= Date: Mon, 7 Oct 2024 19:38:45 +0200 Subject: [PATCH] Allow using character speed for MoveCharacterCommand --- Cutscenes/prototype_start.tres | 1 + Scripts/Characters/base.gd | 3 ++- Scripts/Cutscenes/Commands/move_character.gd | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cutscenes/prototype_start.tres b/Cutscenes/prototype_start.tres index 1428d55..0ee33d3 100644 --- a/Cutscenes/prototype_start.tres +++ b/Cutscenes/prototype_start.tres @@ -15,6 +15,7 @@ time = 1.0 script = ExtResource("3_rxd5p") target_character = NodePath("../HiroAI") target_type = "Node" +use_character_speed = false speed = 75.0 animation_state = "cut_walk" target_vector = Vector2(0, 0) diff --git a/Scripts/Characters/base.gd b/Scripts/Characters/base.gd index 4ca400d..4196e3b 100644 --- a/Scripts/Characters/base.gd +++ b/Scripts/Characters/base.gd @@ -46,7 +46,8 @@ func _on_cutscene_issued_command(command: CutsceneCommand, manager: CutsceneMana movement_scripted_target = command.target_vector if command.target_type == "Vector" else manager.get_node(command.target_node).global_position var approach_direction = global_position.direction_to(movement_scripted_target) set_animation_direction(approach_direction) - velocity = command.speed * approach_direction + var move_speed = speed if command.use_character_speed else command.speed + velocity = move_speed * approach_direction movement_scripted_by = manager movement_scripted_speed = command.speed anim_playback.travel(command.animation_state) diff --git a/Scripts/Cutscenes/Commands/move_character.gd b/Scripts/Cutscenes/Commands/move_character.gd index 769bb98..14217e4 100644 --- a/Scripts/Cutscenes/Commands/move_character.gd +++ b/Scripts/Cutscenes/Commands/move_character.gd @@ -8,6 +8,10 @@ class_name MoveCharacterCommand set(value): target_type = value notify_property_list_changed() +@export var use_character_speed = true: + set(value): + use_character_speed = value + notify_property_list_changed() @export var speed: float = 300 ## AnimationTreeFiniteStateMachine state node that will be transitioned to. @export var animation_state: String = "" @@ -25,3 +29,8 @@ func _validate_property(property: Dictionary): property.usage &= ~PROPERTY_USAGE_READ_ONLY elif property.name == "target_vector" and target_type == "Node": property.usage |= PROPERTY_USAGE_READ_ONLY + + if property.name == "speed" and use_character_speed: + property.usage |= PROPERTY_USAGE_READ_ONLY + elif property.name == "speed" and not use_character_speed: + property.usage &= ~PROPERTY_USAGE_READ_ONLY