Answer the question
In order to leave comments, you need to log in
Physical explosion does not affect Rigbody, how to fix it?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Explosion : MonoBehaviour
{
public float radius;
public float force;
void Start()
{
Collider[] colliders = Physics.OverlapSphere(transform.position, radius);
foreach(Collider nearbyObject in colliders)
{
Rigidbody rb = nearbyObject.GetComponent<Rigidbody>();
if (rb != null)
{
rb.AddExplosionForce(force, transform.position, radius);
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question