31 lines
726 B
C#
31 lines
726 B
C#
using UnityEngine;
|
|
|
|
public class CubeClash_CubeLid : MonoBehaviour
|
|
{
|
|
public float launchForce = 20f;
|
|
public float activeInterval = 8f;
|
|
private float timer;
|
|
|
|
void Update()
|
|
{
|
|
timer += Time.deltaTime;
|
|
if (timer >= activeInterval)
|
|
{
|
|
timer = 0f;
|
|
ActivateLid();
|
|
}
|
|
}
|
|
|
|
void ActivateLid()
|
|
{
|
|
Collider[] cols = Physics.OverlapBox(transform.position, transform.localScale * 0.5f);
|
|
foreach (Collider col in cols)
|
|
{
|
|
if (col.CompareTag("Zibu") && col.attachedRigidbody != null)
|
|
{
|
|
col.attachedRigidbody.AddForce(Vector3.up * launchForce, ForceMode.Impulse);
|
|
}
|
|
}
|
|
}
|
|
}
|