ShaderGraph demo
This commit is contained in:
@@ -5,7 +5,6 @@ public class RocketExplosion : MonoBehaviour
|
||||
[System.Serializable]
|
||||
public class References
|
||||
{
|
||||
public SphereCollider Collider;
|
||||
public ParticleSystem Explosion;
|
||||
}
|
||||
|
||||
@@ -13,15 +12,36 @@ public class RocketExplosion : MonoBehaviour
|
||||
public class Settings
|
||||
{
|
||||
public float Radius = 5;
|
||||
public float Strength = 1000;
|
||||
}
|
||||
|
||||
[SerializeField] private References _references;
|
||||
[SerializeField] private Settings _settings;
|
||||
|
||||
private float radius;
|
||||
private float time;
|
||||
//private float radius;
|
||||
//private float time;
|
||||
|
||||
void Awake()
|
||||
void Start()
|
||||
{
|
||||
Vector3 originPos = transform.position;
|
||||
|
||||
Collider[] colliders = Physics.OverlapSphere(originPos, _settings.Radius);
|
||||
|
||||
foreach (Collider hit in colliders)
|
||||
{
|
||||
Rigidbody rb = hit.GetComponent<Rigidbody>();
|
||||
|
||||
if (rb != null)
|
||||
{
|
||||
float strength = _settings.Strength;
|
||||
strength *= 1 - Vector3.Distance(originPos, hit.transform.position) / _settings.Radius;
|
||||
|
||||
rb.AddExplosionForce(strength, originPos, _settings.Radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*void Awake()
|
||||
{
|
||||
radius = 1;
|
||||
_references.Explosion.Play();
|
||||
@@ -36,5 +56,5 @@ public class RocketExplosion : MonoBehaviour
|
||||
time += Time.deltaTime;
|
||||
if (time > 5)
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user