32 lines
806 B
C#
32 lines
806 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class CubeClash_BirdSwoop : MonoBehaviour
|
|
{
|
|
public float carryHeight = 5f;
|
|
public float carryDuration = 2f;
|
|
private bool carrying = false;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (!carrying && other.CompareTag("Zibu"))
|
|
{
|
|
StartCoroutine(CarryRoutine(other.attachedRigidbody));
|
|
}
|
|
}
|
|
|
|
IEnumerator CarryRoutine(Rigidbody rb)
|
|
{
|
|
carrying = true;
|
|
Vector3 targetPos = rb.position + Vector3.up * carryHeight;
|
|
float t = 0f;
|
|
while (t < carryDuration)
|
|
{
|
|
rb.MovePosition(Vector3.Lerp(rb.position, targetPos, t / carryDuration));
|
|
t += Time.deltaTime;
|
|
yield return null;
|
|
}
|
|
carrying = false;
|
|
}
|
|
}
|