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.

DarkBASIC Professional Discussion / Object Touch Sound

Author
Message
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 22nd Dec 2015 10:13
Hello,

I have loaded multiple sounds and i want them to play when any object touches any object and play the sound corresponding the object's number.

Here is the code:



I don't seem to make it work.

Thank You!
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 22nd Dec 2015 17:16 Edited at: 22nd Dec 2015 17:26
a = phy get collision object a()
b = phy get collision object b()

I do not possess the physics engine but, do these functions not return the id number of the colliding objects. If that is the case, then shouldn’t this work.



In addition, this if condition will only return true if the object collides with itself.

if a = objsndontouch and b = objsndontouch
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 23rd Dec 2015 12:27
Hello WickedX,

It works perfectly, but how can i play the sounds once they are on ground without repeating itself always?

Thank You!
Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 23rd Dec 2015 12:31
It also works with two objects not every object that i assign.
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 23rd Dec 2015 16:35 Edited at: 23rd Dec 2015 18:00
Because the function; Phy Get Collision Data() can only detect a collision between two object per cycle, you should change the while loop to an if/endif condition check. To play the sound once, check if the sound is playing. See how this works.



Unless the physics engine has a function to return the number of collisions and allows you to cycle through each collision checking for a and b, I think this is the best you can hope for.

Edit:
Quote: "but how can i play the sounds once they are on ground without repeating itself always?"


In the snippet the sounds will still repeat once they’re done playing. This would be easier to solve if I knew the available functions in the physics plug-in. If there is a function to check if an object is at rest, you could check if the object is at rest or colliding with the ground before playing the sound. Without knowing more about the physics engine, anything else I could come up with right now would be hacky.

Let me think on this some more. I may have a solution that's not hacky.
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 23rd Dec 2015 22:26
Hello,

I do really appreciate your help, i'll try the code, also please if you do really can find a way to put sounds on multiple objects based on the physics collision that will be absolutely great!

Thank you and Happy Holidays!
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 23rd Dec 2015 23:13 Edited at: 23rd Dec 2015 23:16
You are welcome. Wish you and yours, a Merry Christmas and a Happy New Year.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 28th Dec 2015 02:48 Edited at: 28th Dec 2015 02:50
I have downloaded the Dark Physics Information chm file to familiarize myself with the plug-in. Firstly, if the code in my first post is only playing the sounds of the first two objects colliding, the function - Phy Get Collision Data must be bugged.

This probable won’t help. But, I have been working this out using equivalent functions in ode physics. Seems to be working so far, at least in the version of DBPro I’m using (7.4).
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 28th Dec 2015 13:23
Hello WickedX,

Well, that function is supposed to return for just two objects but i'm thinking if we are using a for loop maybe it will work i don't know.
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 28th Dec 2015 17:27
Dark Physics should internally be storing all collisions on a stack, that is the reason for the while loop. Phy Get Collision Data should iterate through each collision and popping it from the stack until there are not more collisions. Phy Get Collision Object A and Phy Get Collision Object B should return the colliding objects for each iteration.
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 29th Dec 2015 00:30
Ok so what shall we do? Stick to Dark Dynamix?
Alex Matei CEO
www.alexmatei.com
MateiSoft Romania
10
Years of Service
User Offline
Joined: 16th Oct 2013
Location:
Posted: 12th Jan 2016 23:21
Any ideas?
Alex Matei CEO
www.alexmatei.com
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Jan 2016 00:02
I really don’t think I’m equipped to advise you on this. But, if Dark Dynamics can’t do the job then it’s pretty much useless. I would program my own PhysX wrapper. Sorry, can’t be of more help.
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 13th Mar 2016 17:27 Edited at: 13th Mar 2016 17:33
Ok, now that TGC made DarkPhysics available on github. Object Hit and Object Collision seem to work. Hopefully this will work the same with DarkDynamics. Source with executable attached.

Attachments

Login to view attachments
Richard Franklin
8
Years of Service
User Offline
Joined: 10th Mar 2016
Location:
Posted: 16th Mar 2016 14:18
It works perfectly, but how can i play the sounds once they are on ground without repeating itself always?

Login to post a reply

Server time is: 2024-03-29 02:12:38
Your offset time is: 2024-03-29 02:12:38