Files
HeadlessHazard/Assets/Code/Scripts/Enemies/LivingRoot/RootCrawler/RootCrawler.cs

22 lines
481 B
C#

using UnityEngine;
public class RootCrawler : MonoBehaviour
{
public Transform target;
public float maxHeight;
public float crawlingSpeed;
private float height = 0f;
// Update is called once per frame
void Update()
{
if (target == null)
return;
height += Time.deltaTime * crawlingSpeed;
height = Mathf.Clamp(height, 0f, maxHeight);
transform.position = target.position + Vector3.up * height;
}
}