Fix characters missing their scripted target when being pushed by collisions
This commit is contained in:
parent
b92655c56f
commit
4a8434f5a8
3 changed files with 17 additions and 23 deletions
|
@ -33,8 +33,22 @@ func set_animation_direction(direction: Vector2):
|
|||
pass
|
||||
|
||||
func _physics_process(_delta):
|
||||
if movement_scripted_by != null:
|
||||
var approach_direction = global_position.direction_to(movement_scripted_target)
|
||||
set_animation_direction(approach_direction)
|
||||
velocity = movement_scripted_speed * approach_direction
|
||||
if movable:
|
||||
move_and_slide()
|
||||
|
||||
func _process(_delta):
|
||||
if movement_scripted_by != null:
|
||||
var distance_to_target = movement_scripted_target.distance_to(global_position)
|
||||
if distance_to_target <= movement_scripted_speed/60.0:
|
||||
global_position = movement_scripted_target
|
||||
velocity = Vector2.ZERO
|
||||
movement_scripted_by.step()
|
||||
movement_scripted_by = null
|
||||
anim_playback.travel("idle")
|
||||
|
||||
func _on_animation_tree_animation_finished(anim_name):
|
||||
pass
|
||||
|
@ -56,7 +70,7 @@ func _on_cutscene_issued_command(command: CutsceneCommand, manager: CutsceneMana
|
|||
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
|
||||
movement_scripted_speed = move_speed
|
||||
anim_playback.travel(command.animation_state)
|
||||
|
||||
|
||||
|
|
|
@ -49,18 +49,8 @@ func follow_player(speed: float):
|
|||
velocity = speed * approach_direction
|
||||
set_animation_direction(approach_direction)
|
||||
|
||||
func _physics_process(_delta):
|
||||
move_and_slide()
|
||||
|
||||
func _process(_delta):
|
||||
if movement_scripted_by != null:
|
||||
var distance_to_target = movement_scripted_target.distance_to(global_position)
|
||||
if distance_to_target <= movement_scripted_speed/100.0:
|
||||
global_position = movement_scripted_target
|
||||
velocity = Vector2.ZERO
|
||||
movement_scripted_by.step()
|
||||
movement_scripted_by = null
|
||||
anim_playback.travel("idle")
|
||||
func _physics_process(delta: float):
|
||||
super._physics_process(delta)
|
||||
|
||||
func _on_player_attack_did_hit(other, attack_power: int, attack_direction: Vector2):
|
||||
if other.get_parent().get_instance_id() == get_instance_id() :
|
||||
|
|
|
@ -29,16 +29,6 @@ func _unhandled_input(event):
|
|||
velocity = Vector2.ZERO
|
||||
attacked.emit()
|
||||
|
||||
func _process(_delta):
|
||||
if movement_scripted_by != null:
|
||||
var distance_to_target = movement_scripted_target.distance_to(global_position)
|
||||
if distance_to_target <= movement_scripted_speed/60.0:
|
||||
global_position = movement_scripted_target
|
||||
velocity = Vector2.ZERO
|
||||
movement_scripted_by.step()
|
||||
movement_scripted_by = null
|
||||
anim_playback.travel("idle")
|
||||
|
||||
func _physics_process(delta):
|
||||
if in_cutscene:
|
||||
anim_tree.set("parameters/conditions/is_moving", false)
|
||||
|
|
Loading…
Reference in a new issue