fix(miku): correct scale + animation playback
- Fixed Blender export: remove FBX armature modifier before scaling, then transform_apply(scale=True) before creating new armature - Model now exports at correct 1.8 unit height (verified in Blender) - SkinnedPlayerModel now polls MovementStateMachine in _process to drive animations based on movement state - Player 1 gets Miku at origin, others get procedural humanoid at y=-0.9
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -68,10 +68,18 @@ func play_animation(name: String) -> void:
|
||||
else:
|
||||
print("SkinnedPlayerModel: animation '%s' not found" % name)
|
||||
|
||||
func update_state(state: String, speed: float, is_crouching: bool = false) -> void:
|
||||
func _process(delta: float) -> void:
|
||||
if not animation_player:
|
||||
return
|
||||
|
||||
# Poll the movement state machine for current state
|
||||
var sm = get_parent().get_node_or_null("MovementStateMachine")
|
||||
if not sm:
|
||||
return
|
||||
|
||||
var state = sm.current_state
|
||||
var speed = sm.movement_speed
|
||||
|
||||
match state:
|
||||
"ground", "idle":
|
||||
if speed > 1.0:
|
||||
@@ -79,10 +87,18 @@ func update_state(state: String, speed: float, is_crouching: bool = false) -> vo
|
||||
else:
|
||||
play_animation("Idle")
|
||||
"air":
|
||||
play_animation("Idle") # TODO: add jump/fall anim
|
||||
play_animation("Idle")
|
||||
"crouch":
|
||||
play_animation("Idle") # TODO: add crouch anim
|
||||
play_animation("Idle")
|
||||
"slide":
|
||||
play_animation("Run") # TODO: add slide anim
|
||||
play_animation("Run")
|
||||
"wall_run":
|
||||
play_animation("Run")
|
||||
"wall_cling":
|
||||
play_animation("Idle")
|
||||
"grapple":
|
||||
play_animation("Run")
|
||||
"dash":
|
||||
play_animation("Run")
|
||||
_:
|
||||
play_animation("Idle")
|
||||
|
||||
@@ -370,14 +370,15 @@ func _spawn_player(pid: int) -> CharacterBody3D:
|
||||
player.set_script(mover_script)
|
||||
|
||||
# Visual Model for Player
|
||||
# Player 1 gets the Miku skinned model, others get procedural humanoid
|
||||
if pid == 1:
|
||||
# Miku: use the rigged GLB model with its own armature
|
||||
var skinned = load("res://characters/skinned_player_model.gd").new()
|
||||
skinned.name = "SkinnedModel"
|
||||
skinned.model_path = "res://assets/characters/skins/miku_rigged_final.glb"
|
||||
skinned.position = Vector3(0, -0.9, 0)
|
||||
skinned.position = Vector3.ZERO # Model origin = player origin
|
||||
player.add_child(skinned)
|
||||
else:
|
||||
# Default: procedural humanoid
|
||||
var humanoid = load("res://characters/humanoid_model.gd").new()
|
||||
humanoid.name = "HumanoidModel"
|
||||
humanoid.color = Color(0.2, 0.4, 0.8)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
@tool
|
||||
extends EditorScript
|
||||
|
||||
func _run():
|
||||
var source = "res://assets/characters/skins/miku_rigged_final.glb"
|
||||
var dest = "res://assets/characters/skins/miku_rigged_imported.tscn"
|
||||
|
||||
print("Loading %s..." % source)
|
||||
var glb = load(source)
|
||||
if not glb:
|
||||
print("ERROR: Failed to load GLB")
|
||||
return
|
||||
|
||||
print("Instantiating...")
|
||||
var scene = glb.instantiate()
|
||||
if not scene:
|
||||
print("ERROR: Failed to instantiate")
|
||||
return
|
||||
|
||||
print("Scene: %s" % scene.name)
|
||||
print("Children:")
|
||||
for child in scene.get_children():
|
||||
print(" %s (%s)" % [child.name, child.get_class()])
|
||||
if child is Skeleton3D:
|
||||
print(" Bones: %d" % child.get_bone_count())
|
||||
if child is AnimationPlayer:
|
||||
print(" Animations: %s" % child.get_animation_list())
|
||||
|
||||
# Save as scene
|
||||
var packed = PackedScene.new()
|
||||
packed.pack(scene)
|
||||
ResourceSaver.save(packed, dest)
|
||||
print("Saved to %s" % dest)
|
||||
Reference in New Issue
Block a user