fix 动画状态流转

master
chendian 8 months ago
parent fd1688efa0
commit 45b5b5037b

@ -81,7 +81,7 @@ metadata/_editor_floor_ = Vector3(0, 6, 0)
[node name="BornPos" type="Node3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 78.4802, 2, 3.99949)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.12304, 2, 3.99949)
[node name="Sprite3D" type="Sprite3D" parent="."]
transform = Transform3D(640, 0, 0, 0, 320, 0, 0, 0, 1, 281.6, -19.2, 0)

@ -45,7 +45,9 @@ func move_tick(delta) -> bool:
func update_on_floor() -> bool:
var is_on_floor: bool = character.is_on_floor()
var is_hit: bool = not status.is_on_floor and is_on_floor
status.set_status("is_on_floor", is_on_floor)
if status.is_on_floor != is_on_floor:
status.set_status("is_on_floor", is_on_floor)
status.emit_status("speed_xz")
if status.is_on_floor and not status.is_jumping:
status.set_status("is_jumped", false)
var is_skill_running: bool = status.is_skill_running and status.break_level != Enum.EBreakLevel.Walk
@ -87,7 +89,9 @@ func update_move(delta):
character.velocity.x = move_velocity.x
character.velocity.z = move_velocity.y
status.set_status("speed_xz", Vector2(character.velocity.x, character.velocity.z).length())
var speed_xz = Vector2(character.velocity.x, character.velocity.z).length()
if abs(status.speed_xz - speed_xz) > 0.1:
status.set_status("speed_xz", Vector2(character.velocity.x, character.velocity.z).length())
if status.is_free_turn and status.move_dir.x != 0:
status.set_status("is_right", status.move_dir.x > 0)
@ -152,7 +156,7 @@ func update_move_check(_delta) -> bool:
Global.effect_mgr.cast_particle(ResourceManager.particle_hit_ground_normal, character.pos(), normal)
character.velocity = velocity - normal * normal_speed * 1.5
character.add_buff("floating", -1)
Global.camera_mgr.effect_shake(0.1)
character.set_view_trigger("rebound")
if normal.y == 0:
if not status.is_stagger:
status.is_hit_wall = true

@ -35,7 +35,7 @@ func reset():
play_animation("jump4_loop")
func trans_register() -> void:
# 地面行走
#地面行走
trans("idle_loop", "run1", "speed_xz", ">", 1)
run("run1", "run2_loop")
trans("run1", "run3", "speed_xz", "<", 1)
@ -43,11 +43,20 @@ func trans_register() -> void:
run("run3", "idle_loop")
trans("run3", "run1", "speed_xz", ">", 1)
# 跳跃
#下落
trans("idle_loop", "jump4_loop", "is_on_floor", "=", false)
trans("run1", "jump4_loop", "is_on_floor", "=", false)
trans("run2_loop", "jump4_loop", "is_on_floor", "=", false)
trans("run3", "jump4_loop", "is_on_floor", "=", false)
#跳跃
trigger("any", "jump1", "trigger_jump")
run("jump1", "jump2_loop")
trans("jump2_loop", "jump3", "speed_y", "<=", 0)
run("jump3", "jump4_loop")
#跳跃落地
trans("jump3", "jump5", "is_on_floor", "=", true)
trans("jump4_loop", "jump5", "is_on_floor", "=", true)
run("jump5", "idle_loop")
trans("jump5", "run1", "speed_xz", ">", 1)
@ -56,9 +65,12 @@ func trans_register() -> void:
trigger("any", "hit", "trigger_hit")
trigger("any", "mhit", "trigger_mhit")
trigger("any", "lhit", "trigger_lhit")
run("hit", "idle_loop")
run("mhit", "idle_loop")
run("lhit", "idle_loop")
run_with_condition("hit", "idle_loop", "is_on_floor", "=", true)
run_with_condition("mhit", "idle_loop", "is_on_floor", "=", true)
run_with_condition("lhit", "idle_loop", "is_on_floor", "=", true)
run_with_condition("hit", "jump4_loop", "is_on_floor", "=", false)
run_with_condition("mhit", "jump4_loop", "is_on_floor", "=", false)
run_with_condition("lhit", "jump4_loop", "is_on_floor", "=", false)
#地面眩晕受击
trigger("any", "stunhit", "trigger_stun_hit")
@ -70,9 +82,12 @@ func trans_register() -> void:
run("airhit1", "airhit2_loop")
trans("airhit2_loop", "airhit3", "speed_y", "<=", 0)
run("airhit3", "airhit4_loop")
trans("airhit4_loop", "airhit5_select", "is_on_floor", "=", true)
#空中受击落地
trans("airhit1", "airhit5_select", "is_on_floor", "=", true)
trans("airhit2_loop", "airhit5_select", "is_on_floor", "=", true)
trans("airhit3", "airhit5_select", "is_on_floor", "=", true)
trans("airhit4_loop", "airhit5_select", "is_on_floor", "=", true)
run_with_condition("airhit5_select", "airhit5_stun", "is_stun", "=", true)
run_with_condition("airhit5_select", "airhit5", "is_stun", "=", false)
run("airhit5_stun", "ground_stun1_loop")
@ -87,14 +102,16 @@ func trans_register() -> void:
#落地反弹
trigger("any", "rebound", "trigger_rebound")
run("rebound", "airhit2_loop")
run_with_condition("rebound", "airhit2_loop", "is_on_floor", "=", false)
run_with_condition("rebound", "airhit5_select", "is_on_floor", "=", true)
func _process(_delta) -> void:
if status.is_be_throw: return
if status.is_pause: return
for status_change_cache_single in status_change_cache:
update_trans(status_change_cache_single)
status_change_cache.clear()
if status_change_cache:
for status_change_cache_single in status_change_cache:
update_trans(status_change_cache_single)
status_change_cache.clear()
func _on_character_status_changed(status_name, _value) -> void:
if status_name in trans_dict:

@ -17,7 +17,8 @@ func _process(_delta: float) -> void:
return
refresh_debug_info("硬直等级", str(player.get_status("break_level")))
refresh_debug_info("姿态", str(player.get_status("stance")))
refresh_debug_info("位置", Global.level_mgr.get_cur_level_name() + str(Util.get_level_grid_pos2(player.pos())))
refresh_debug_info("关卡位置", Global.level_mgr.get_cur_level_name() + str(Util.get_level_grid_pos2(player.pos())))
refresh_debug_info("动画状态", ("地面" if player.get_status("is_on_floor") else "空中") + "-" + player.get_status("current_animation"))
func refresh_debug_info(label_value: String, value: String) -> void:

Loading…
Cancel
Save