Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark Physics & Dark A.I. & Dark Dynamix / sync up audio with collision ?

Author
Message
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 1st Jul 2008 07:16 Edited at: 1st Jul 2008 07:34
I'm stacking up barrels and would like to play "bang" sounds as they fall and collide with each other and the floor.

First, dynamic meshes dont work so I'm using dynamic boxes for now till it gets fixed.



I used phy get collision data() and that gave me tons of collisions. I want to know what can I set to get less collisions reported.

What I mean is when two barrels are stacked ontop of each other I dont want to get a continuous sound because of the tiny collision happening between the two.

I tried messing with friction, momentum, and angular velocity to adjust the collision threshold but no luck.

any suggestions?

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 2nd Jul 2008 00:09 Edited at: 2nd Jul 2008 00:11
try this it`s what i did for my demo .



chunks

toshiba satellite 1.6 core duo + nvidia geforce go 7300
windows xp pro.
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 2nd Jul 2008 03:28
This is what I am dealing with at the moment also. In short, due to time, you can always check the general velocities of each object in a collision.

To do this you will need each object's current position(all three coords) and their last position(position on last loop). So, at the end of your loop record the barrels' positions in an array.

EX:


Upon the next loop check the speed of each collision object that is a barrel.

EX:


This will give you a positive speed value of some degree. You'll have to play with it a bit to get it perfect, but you can set your own threshold so that the sound will only play if either object is falling faster than the threshold.

EX:


This may not be a perfect method yet, but work with it. I think you'll be able to figure something that works.
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 3rd Jul 2008 04:26 Edited at: 3rd Jul 2008 04:26
Thank you all,

@Nano brain
Thanks, it helped a lot. I hoped they have something like this in DP since audio on collision is only the next logical step.

for my game instead of (if speed#>3 then play sound) I had to keep track of speed# and oldspeed# like you did with the positions, and get the Abs difference to give me more control over the threshold.

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 4th Jul 2008 14:18
Trogdor,

I'm not sure I understand how calculating old and new speeds helps precision. Maybe an explanation for my future sake could be useful. However, I'm glad that I was clear enough to help you.
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 10th Jul 2008 00:15
sorry about the late response but here's how I ended up doing



I noticed that when checking the speed the numbers change as the object bounce but when it comes to its last couple of secs the speed ramains the same and it only changes after the decimal causing a machine gun kind of sound. This is why I get the Abs difference so I can ignore stuff after the 3rd decimal value.

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 10th Jul 2008 06:35
Here's a link to see it in action.
http://www.youtube.com/watch?v=74lRxJmnhIM

It's a good sync most of the time. Every once in a while I'll get a collision sound when everything seems to be still (need to tweak the threshold a bit more).

I dont like using dynamic boxes for barrels, but I have to wait till they fix the dynamic meshes in the next DP I hope...

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 10th Jul 2008 23:24
trogdor,

Good job so far! Simple as it was, the video was kind of entertaining...heheh. I'm not sure exactly what to do about the sound playing on occassion when it shouldn't be. I suppose you could set a barrel's state to "no sound play" once it has come to 'rest'. Then, once the barrel begins to move again, set it's state to "play sounds".

I have not had to go so far as this, due to the velocity checking working perfectly fine. I'm glad this has brought you past this hurdle.
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 15th Jul 2008 21:49
@Nano Brain
I've updated the sound code due to a typo that threw my numbers off.

In your example you had


which supposed to be


I did not see the typo till today

Now with that x changed to a z, I do not get those unexpected sounds, and I do not need the extra speed checks.

Velocity checking works good now

here's my updated code...



Please take a look at how I ray cast and place a red ball as a visual cue to the ray cast hit point.

When I click my mouse I apply force to a barrel but they don't respond all the time.

Do you see something off, or is there a better way than I've done?

Thanks again,

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
Nano brain
16
Years of Service
User Offline
Joined: 7th May 2008
Location:
Posted: 16th Jul 2008 10:54
From the looks of it, my 'paper in the wind' assumption is that it could have to do with the
section of your code.

That section in full:


If the dot object is spot on, then there is no other reason it should not work, except that some incorrect values are being returned from the colarr() array. I would have to see your code in full to make any greater of an assesment on this issue though.
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 17th Jul 2008 09:07 Edited at: 18th Jul 2008 00:54
When I move the mouse, the redball skims over the barrels and I get the object number on the screen, so I know that part works.

but when I click the mouse somtimes nothing happens. I'm thinking maybe its in the way I apply force on the barrels.



or maybe somthing fishy is happening with PHY RAY CAST CLOSEST SHAPE and collisions afterwards.


EDIT: I did more testing and its not my code, PHY RAY CAST CLOSEST SHAPE is buggy, sometimes it does not report a collision.

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
Random color object
16
Years of Service
User Offline
Joined: 14th Aug 2008
Location: Montreal Canada
Posted: 12th Sep 2008 00:26
is it your video here
http://www.youtube.com/watch?v=74lRxJmnhIM

When it is too complicated it is because you are trying at the wrong door.
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 12th Sep 2008 18:17
yep, thats mine.
I've also added an extra phy update call to speed things up.
Now, it runs, twice as fast.

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
Random color object
16
Years of Service
User Offline
Joined: 14th Aug 2008
Location: Montreal Canada
Posted: 12th Sep 2008 22:54 Edited at: 12th Sep 2008 23:24
what you place phy update 2 time in the loop and it run twice faster?

sound collision

I made this from the demo collision data
notice I place
if a >1
play sound 1
but there is a delay kinda.



I change my sound, put a smaller one. Notice 2 tings.
1. There was alot of collisions when the clock is finishing to clollide.
2. The 3nd block is coliding but the sound is delayed.

When it is too complicated it is because you are trying at the wrong door.
trogdor
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: Portsmouth, VA, USA
Posted: 13th Sep 2008 00:33
There're so much collision data the way you do it, so the delay you hear is many Tom1.wav playing back to back and you are hearing only the last one.

You need to filter out many of those collision by calculating each object speed on collision, then adjust the sensitivity to when you'd like to play a collision sound.

Your code should look something like this




you'll see I have two phy updates. comment out the one after the for loop and see how slow it gets.

If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.
Random color object
16
Years of Service
User Offline
Joined: 14th Aug 2008
Location: Montreal Canada
Posted: 13th Sep 2008 01:06 Edited at: 13th Sep 2008 02:46
Oh ya it is much faster, I get to ear all the collisions of the 3th block. As my sound is less than a sec I ear alot of them. I have to admit that it can be tricky to get a specific result. Have you ever try Environmental Audio Effects in the enhanced pack, there is all kind of interesting effects that can be apply to the wav like:
Room effect, digital delay, reverb, air absorption and many more?

For my code: the 3 cubes. If a>1 and sound was played in the last 1 sec, don't play any sound. Some kind of IF like that could fix easily the problem of rebouncing making multiple sounds.

When it is too complicated it is because you are trying at the wrong door.

Login to post a reply

Server time is: 2024-11-24 21:17:30
Your offset time is: 2024-11-24 21:17:30