feat: add witnessed knowledge and wind ambience
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var body_mesh: MeshInstance3D = $Body
|
||||
@onready var head_mesh: MeshInstance3D = $Head
|
||||
@onready var hair_mesh: MeshInstance3D = $Hair
|
||||
@onready var left_arm: MeshInstance3D = $ArmLeft
|
||||
@onready var right_arm: MeshInstance3D = $ArmRight
|
||||
@onready var left_leg: MeshInstance3D = $LegLeft
|
||||
@onready var right_leg: MeshInstance3D = $LegRight
|
||||
|
||||
var player_body: CharacterBody3D
|
||||
var walk_phase := 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
player_body = get_parent() as CharacterBody3D
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if player_body == null:
|
||||
return
|
||||
var horizontal_speed := Vector2(player_body.velocity.x, player_body.velocity.z).length()
|
||||
var blend := minf(delta * 10.0, 1.0)
|
||||
if horizontal_speed > 0.1:
|
||||
walk_phase = fmod(walk_phase + delta * horizontal_speed * 3.4, TAU)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
Reference in New Issue
Block a user