feat(characters): add modular woodland traveler kit
This commit is contained in:
+21
-9
@@ -1,5 +1,9 @@
|
||||
extends Node3D
|
||||
|
||||
@export var appearance: CharacterAppearanceProfile = preload(
|
||||
"res://assets/characters/profiles/reference_cat.tres"
|
||||
)
|
||||
|
||||
@onready var body_mesh: MeshInstance3D = $Body
|
||||
@onready var head_mesh: MeshInstance3D = $Head
|
||||
@onready var hair_mesh: MeshInstance3D = $Hair
|
||||
@@ -10,11 +14,15 @@ extends Node3D
|
||||
|
||||
var player_body: CharacterBody3D
|
||||
var walk_phase := 0.0
|
||||
var rest_heights := Vector3(1.05, 1.68, 1.9)
|
||||
var arm_swing := 1.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
player_body = get_parent() as CharacterBody3D
|
||||
AnimalAppearance.apply_to(self, 0)
|
||||
AnimalAppearance.apply_to(self, 0, false, appearance)
|
||||
rest_heights = AnimalAppearance.rest_heights(self)
|
||||
arm_swing = get_meta("arm_swing", 1.0)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -27,18 +35,22 @@ func _process(delta: float) -> void:
|
||||
var swing := sin(walk_phase)
|
||||
left_leg.rotation_degrees.x = lerpf(left_leg.rotation_degrees.x, swing * 30.0, blend)
|
||||
right_leg.rotation_degrees.x = lerpf(right_leg.rotation_degrees.x, -swing * 30.0, blend)
|
||||
left_arm.rotation_degrees.x = lerpf(left_arm.rotation_degrees.x, -swing * 22.0, blend)
|
||||
right_arm.rotation_degrees.x = lerpf(right_arm.rotation_degrees.x, swing * 22.0, blend)
|
||||
left_arm.rotation_degrees.x = lerpf(
|
||||
left_arm.rotation_degrees.x, -swing * 22.0 * arm_swing, blend
|
||||
)
|
||||
right_arm.rotation_degrees.x = lerpf(
|
||||
right_arm.rotation_degrees.x, swing * 22.0 * arm_swing, blend
|
||||
)
|
||||
var step_bob := absf(sin(walk_phase * 2.0)) * 0.035
|
||||
body_mesh.position.y = lerpf(body_mesh.position.y, 1.05 + step_bob, blend)
|
||||
head_mesh.position.y = lerpf(head_mesh.position.y, 1.68 + step_bob, blend)
|
||||
hair_mesh.position.y = lerpf(hair_mesh.position.y, 1.9 + step_bob, blend)
|
||||
body_mesh.position.y = lerpf(body_mesh.position.y, rest_heights.x + step_bob, blend)
|
||||
head_mesh.position.y = lerpf(head_mesh.position.y, rest_heights.y + step_bob, blend)
|
||||
hair_mesh.position.y = lerpf(hair_mesh.position.y, rest_heights.z + step_bob, blend)
|
||||
return
|
||||
|
||||
left_leg.rotation_degrees.x = lerpf(left_leg.rotation_degrees.x, 0.0, blend)
|
||||
right_leg.rotation_degrees.x = lerpf(right_leg.rotation_degrees.x, 0.0, blend)
|
||||
left_arm.rotation_degrees.x = lerpf(left_arm.rotation_degrees.x, 0.0, blend)
|
||||
right_arm.rotation_degrees.x = lerpf(right_arm.rotation_degrees.x, 0.0, blend)
|
||||
body_mesh.position.y = lerpf(body_mesh.position.y, 1.05, blend)
|
||||
head_mesh.position.y = lerpf(head_mesh.position.y, 1.68, blend)
|
||||
hair_mesh.position.y = lerpf(hair_mesh.position.y, 1.9, blend)
|
||||
body_mesh.position.y = lerpf(body_mesh.position.y, rest_heights.x, blend)
|
||||
head_mesh.position.y = lerpf(head_mesh.position.y, rest_heights.y, blend)
|
||||
hair_mesh.position.y = lerpf(hair_mesh.position.y, rest_heights.z, blend)
|
||||
|
||||
Reference in New Issue
Block a user