32 lines
711 B
C#
32 lines
711 B
C#
using UnityEngine;
|
|
|
|
public class CubeClash_Butterfly : MonoBehaviour
|
|
{
|
|
public Transform followTarget;
|
|
public float followSpeed = 2f;
|
|
public float hoverHeight = 1.5f;
|
|
public float lifeTime = 5f;
|
|
|
|
void Start()
|
|
{
|
|
Destroy(gameObject, lifeTime);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (followTarget)
|
|
{
|
|
Vector3 targetPos = followTarget.position + Vector3.up * hoverHeight;
|
|
transform.position = Vector3.Lerp(transform.position, targetPos, followSpeed * Time.deltaTime);
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.CompareTag("Zibu"))
|
|
{
|
|
followTarget = other.transform;
|
|
}
|
|
}
|
|
}
|