using UnityEngine; public class RootCrawler : MonoBehaviour { public Transform target; public float maxHeight; public float crawlingSpeed; public float radius = 0.5f; public float rotationSpeed = 5f; private float height = 0f; private float angle = 0f; void Update() { if (target == null) return; height += Time.deltaTime * crawlingSpeed; height = Mathf.Clamp(height, 0f, maxHeight); angle += Time.deltaTime * rotationSpeed; float x = Mathf.Cos(angle) * radius; float z = Mathf.Sin(angle) * radius; Vector3 basePos = target.position; Vector3 offset = new Vector3(x, height - 0.8f, z); transform.position = basePos + offset; Debug.DrawLine(target.position, transform.position, Color.red); } }