- Home /
Question by
Soareverix · Feb 02, 2020 at 10:12 PM ·
c#collisionrigidbodyscene
How do I detect how many collisions are happening in game (for all objects in a scene?)
I'm working on making a destruction game and I want a sort of "destruction meter" based on how many objects are colliding and at what velocities. I know how to get collisions between one object and other objects but is there a way to determine how many collisions are happening in the scene at the same time? This would help me a ton and open the door to adding some neat procedural sound effects.
Comment
Answer by LeFlop2001 · Feb 02, 2020 at 10:20 PM
You could simply have a reference to game manager on all colliding objects and call a Funktion on that manager every time something collides
Create One $$anonymous$$ethod For Calculating collisions.`
And call method from OnCollisionEnter
public void Add()
{
collisioncount++;
}
private void OnCollisionEnter(Collision collision)
{
Add();
}