Hello
I am looking to add sounds when objects collide, i am trying to see what is the best way to do this.
Are there any best practices?
It seems that i would need to maintain an Enter/Stay/Exit state inside ICollisionEventsJob for every object that i need to handle sounds?
Is there anything more optimal?
How can i tell how hard an object hit a surface to see what sound to play?
Is CollisionEvent.Details.EstimatedImpulse my best bet?
Thank you!!
Hi @argibaltzi , you’re right about everything and collision events are the intended solution for your use case. You can see how we did stateful events in UnityPhysicsSamples\Assets\Demos\2. Setup\2d. Events\2d2. Collision Events\Scripts\DynamicBufferCollisionEventAuthoring.cs . If you want to keep playing sounds as long as bodies are colliding, you can do it simply without the state.
CollisionEvent.Details.EstimatedImpulse will tell you how “strong” the collision was.
Please let me know if you have any further questions.
2 Likes