Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/PPFXPhysicForce.cs
2026-02-21 16:45:37 +08:00

34 lines
792 B
C#

using System.Collections;
using UnityEngine;
public class PPFXPhysicForce : MonoBehaviour
{
public float radius = 10f;
public float force = 10f;
public float delay = 0.2f;
private Collider[] colliders;
private void Start()
{
colliders = Physics.OverlapSphere(base.transform.position, radius);
StartCoroutine(Explode());
}
private IEnumerator Explode()
{
yield return new WaitForSeconds(delay);
for (int i = 0; i < colliders.Length; i++)
{
Rigidbody component = colliders[i].GetComponent<Rigidbody>();
if (component != null)
{
colliders[i].GetComponent<Rigidbody>().AddExplosionForce(force, base.transform.position, radius, new Vector3(Random.Range(-3, 3), Random.Range(-3, 3), Random.Range(-3, 3)), ForceMode.Impulse);
}
}
yield return null;
}
}