36 lines
1.7 KiB
GDScript
36 lines
1.7 KiB
GDScript
|
|
extends "res://catwalk.gd"
|
||
|
|
# Approved Infernal locomotion: grounded heels and gentle secondary motion.
|
||
|
|
var secondary_time=0.0
|
||
|
|
|
||
|
|
func _init():
|
||
|
|
stride_min=.95;stride_max=1.15;track_width=.09;swing_height=.11
|
||
|
|
|
||
|
|
func ground_height(f):
|
||
|
|
return actor.get_parent().global_position.y+f.rest.y*actor.global_basis.get_scale().y+.004
|
||
|
|
|
||
|
|
func update(dt):
|
||
|
|
super.update(dt)
|
||
|
|
secondary_time+=dt
|
||
|
|
for side in ["L","R"]:
|
||
|
|
var sign_x=1.0 if side=="L" else -1.0
|
||
|
|
rotate_world("Wing."+side,actor.global_basis.y,sign_x*sin(phase*TAU-.7)*.035*walk_weight)
|
||
|
|
rotate_world("Wing."+side,actor.global_basis.z,sign_x*sin(phase*TAU*2-.5)*.022*walk_weight)
|
||
|
|
rotate_world("Wing."+side,actor.global_basis.y,sign_x*sin(secondary_time*.8)*.010)
|
||
|
|
var tail_angle=sin(secondary_time*.95)*.012+sin(phase*TAU-.9)*.024*walk_weight
|
||
|
|
rotate_world("Tail",actor.global_basis.y,tail_angle)
|
||
|
|
rotate_world("Tail",actor.global_basis.x,sin(secondary_time*.7)*.006)
|
||
|
|
|
||
|
|
func foot_orientation(f,dt):
|
||
|
|
var body_yaw=actor.global_rotation.y
|
||
|
|
# The planted shoe may pivot, but the ankle must never remain twisted behind
|
||
|
|
# a turning shin. Keep its heading within an anatomical range of the pelvis.
|
||
|
|
var difference=wrapf(f.yaw-body_yaw,-PI,PI)
|
||
|
|
if absf(difference)>deg_to_rad(22):f.yaw=body_yaw+clampf(difference,-deg_to_rad(22),deg_to_rad(22))
|
||
|
|
var yaw=f.yaw if f.grounded else lerp_angle(f.yaw,body_yaw,minf(1,dt*18))
|
||
|
|
if not f.grounded:f.yaw=yaw
|
||
|
|
var orientation=Quaternion(Vector3.UP,yaw)*f.rotation
|
||
|
|
# A high heel has a rigid arch. Lift the whole shoe with the leg rather than
|
||
|
|
# sharply flexing its toe or rolling it onto the outer edge during swing.
|
||
|
|
var roll=sin(clampf((f.last_phase-.5)*2,0,1)*PI)*-.045 if not f.grounded else 0.0
|
||
|
|
return Quaternion(actor.global_basis.x.normalized(),roll)*orientation
|