Sign in to follow this  
glad

car collision sound playing

Recommended Posts

Hi all! First of all I appologise for my broken English. I have a situation: I have to make a car sound collision sound. When the car is collide with the house, for example, the crash sound must be spawned at collision place. If the car have grinding along the house wall we play the grind sound. In the code physics layer give me a set of collision points. How I did it: Get a list of collision points normals to surface, then sum it, and normalize to a unit vector. Then calculate an angle between this vector and velocity vector of the car. If the angle is too small then I play one sound, else another. The problem is: sometimes I hear the grind sound instead of crash. I suppose this is because the normals have a big dispersion.. May be the problem is not in this. I need some help, some advises. May you confront with such problems. Thanks.

Share this post


Link to post
Share on other sites
It might make it easier to associate the sounds to the breakable object itself instead of the car. So if a wall object (for example) detects that it's been hit by something and decides whether the force of the hit is enough to break it. If so, the wall shatters and the crash sound is played. if not, the wall remains and the grinding sound is played. Disassociating the sound from the car object also lets you use them for any game object that may grind against or crash through a wall (if the sounds are generic enough).

If you need the sound to sound specifically like a car crashing tho... prob not an option.

Share this post


Link to post
Share on other sites
Quote:
Original post by Gaiiden
It might make it easier to associate the sounds to the breakable object itself instead of the car. So if a wall object (for example) detects that it's been hit by something and decides whether the force of the hit is enough to break it. If so, the wall shatters and the crash sound is played. if not, the wall remains and the grinding sound is played. Disassociating the sound from the car object also lets you use them for any game object that may grind against or crash through a wall (if the sounds are generic enough).

If you need the sound to sound specifically like a car crashing tho... prob not an option.


It is a good idea, but only for comfortable code organization.. It's not solve a problem..

There is different kinds of objects: static, dynamic, dynamic breakable. F.e. house is a static object. You probably suggest to calculate the kinetics energy on the object. E = mv^2/2; But.. I can grind among the wall with a high velocity value and kinetics energy will staisfy an energy of crashing sound.. Or.. I can slowly (but not very slowly) crash to the wall and hear some crash sound.. But not a grind..

Im thinking now about continuation of your idea: each object have itself collision model.. But it is just a thoughts aloud.

----------------

P.S. If the object is more complex then just a wall that is the problem.. F.e. house that not simply a box or something more complex.. or lamppost or.. or..
=(

Share this post


Link to post
Share on other sites
Figured as much. It was one of those ideas that sounds good in your head, but when you actually write it down... *shrug* I figured I'd post it anyways cause you never know.

Share this post


Link to post
Share on other sites
Quote:
Original post by Gaiiden
Figured as much. It was one of those ideas that sounds good in your head, but when you actually write it down... *shrug* I figured I'd post it anyways cause you never know.


Of course it's just some ideas.. Thank you for your help.

No more comments ? =)

I think I remain in all alone with this trouble

Share this post


Link to post
Share on other sites
to put it simply, you just need the normal of collision (n) and the velocity vector (or relative velocity vector if you have two cars fdor example) (v).

the magnitude of the impact sound would depend on the magnitude of the dot product.

impact = fabs(v . n).

The grind sound would be depedent of the magnitude of the tangential component of the velocity.


Vector tangent = v - (v . n) * n;
grind = tangent.length();


that should give you a reasonable approximation. You will most likely need to smooth out the sound over a preiod of time. The problem with grind sound is that it's usually looping, but collisions happen over a short period of time.

for example, ...

Vector currentTangent = v - (v . n) * n;
float currentImpact = fabs(v . n);
float currentGrind = currentTangent.length();

impact = currentImpact;
grind += (currentGrind - grind) * 0.3

Share this post


Link to post
Share on other sites
Quote:
Original post by oliii
to put it simply, you just need the normal of collision (n) and the velocity vector (or relative velocity vector if you have two cars fdor example) (v).

the magnitude of the impact sound would depend on the magnitude of the dot product.

impact = fabs(v . n).

The grind sound would be depedent of the magnitude of the tangential component of the velocity.


Vector tangent = v - (v . n) * n;
grind = tangent.length();


that should give you a reasonable approximation. You will most likely need to smooth out the sound over a preiod of time. The problem with grind sound is that it's usually looping, but collisions happen over a short period of time.

for example, ...

Vector currentTangent = v - (v . n) * n;
float currentImpact = fabs(v . n);
float currentGrind = currentTangent.length();

impact = currentImpact;
grind += (currentGrind - grind) * 0.3


Hi!
Thanks a lot.
My calculations very similar to yours..
But, You do not consider that physics layer is not ideal. In reality we have an array of collision points... For example, lamppost: in the begining the car goes little through lamppost then physics turn begins and physics says: "Hey.. We have collision here" and give to us a huge array of collision points.. Which one should I take ? For now I just make a sum of normals to surface in each collision point and normalize this vector to a unit vector. But it's not always will work..

Quote:
The problem with grind sound is that it's usually looping, but collisions happen over a short period of time.


This problem I had already solved.

Quote:
grind += (currentGrind - grind) * 0.3


This is interesting one =) I had never thought about such formula =)
I make it like this:
if (currTangent > minTangent)
{
if (currTangent < maxTangent)
volume = (currTangent - minTangent)/(maxTangent - minTangent)
else
volume = 1.0f;
}
else
volume = 0.0f;

This is like "by the way" =)

Share this post


Link to post
Share on other sites
You calculations are fine.

For the multiple contact points, you could take the highest of the dot products as your collision sound (v . n). Same for the friction sound.

Share this post


Link to post
Share on other sites
Quote:
Original post by oliii
You calculations are fine.

For the multiple contact points, you could take the highest of the dot products as your collision sound (v . n). Same for the friction sound.


=)
It is not a good decision IMHO. But.. I can be wrong.
In any event thanks for the help =)

Share this post


Link to post
Share on other sites
That stuff works best with trial and error. There are just too many things specific to what you want to achieve. There is no 'one' algorithm to do what you want.

I could for example, use a sort of 'expanding bubble' to group contact points that are close to each other, do some sort of weighted average, use the energy conservation to work out exactly how much energy has been lost in the collision (energy lost -> material deformation, heat, sound) ... Many things that can be done.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this