using UnityEngine; namespace HotUpdate.Gameplay { /// Placeholder explorer: swings the authored legs while the root is moved. public sealed class ExplorerPuppet : MonoBehaviour { Transform _legL, _legR, _body; Vector3 _last; Vector3 _bodyRest; void Awake() { _legL = transform.Find("LegL"); _legR = transform.Find("LegR"); _body = transform.Find("Body"); if (_body != null) _bodyRest = _body.localPosition; _last = transform.position; } void LateUpdate() { Vector3 delta = transform.position - _last; _last = transform.position; float speed = new Vector2(delta.x, delta.z).magnitude / Mathf.Max(Time.deltaTime, 0.0001f); bool walking = speed > 0.05f; float swing = walking ? Mathf.Sin(Time.time * 8f) * 32f : 0f; if (_legL != null) _legL.localRotation = Quaternion.Euler(swing, 0, 0); if (_legR != null) _legR.localRotation = Quaternion.Euler(-swing, 0, 0); if (_body != null) _body.localPosition = _bodyRest + Vector3.up * (walking ? Mathf.Abs(Mathf.Sin(Time.time * 8f)) * 0.05f : Mathf.Sin(Time.time * 2f) * 0.015f); } } }