Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[OPEN SOURCE] PhysSound Physics Audio System

Discussion in 'Assets and Asset Store' started by crazymonkay, Jun 17, 2015.

  1. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    206
    hey there. we just started using your asset and I was wondering if you could point me in the right direction

    So we have a desk drawer that we want to use a slide and impact sound for. (The user can actually pull and push the drawer). The drawer is on a configurable joint, rigidbody, and box collider. While the rest of the desk is on a mesh collider (non-convex). We have a slide sound, and an impact sound for the close.
    From what I have initially, I think my numbers might be off, because the slide doesn't come through. But the slide is constantly changing the volume on the AudioSource even when not being moved.

    Any recommendations on number tweaks for this effect?
     
  2. jeyb

    jeyb

    Joined:
    Oct 3, 2014
    Posts:
    2
    Bought this yesterday and spent a while figuring out why it was duplicating sounds. Overall, I think it needs to be more intelligent about when sounds are played.

    There's currently no option to turn off playing sounds on OnTrigger events. I have objects with triggers to allow them to be interacted with and separate colliders for physics. This was doubling the number of times sounds played as both trigger and collider played.

    I'd like it if compound colliders were handled better too. For example, I have a key made of 2 colliders. When the key lands and is entirely flat, you'd expect there to be one sound played of the single surface of the key hitting the other object. Instead, because each collider sends messages separately you'll get multiple sounds.

    I tacked in something to only play a single impact sound per object per fixed update and I think this works okay though I haven't looked at whether that would have any other consequences.

    Edit: Actually I swapped it out for a minimum time between impact sounds per object. It's slightly less realistic but means you get far fewer cut off sounds and overall sounds better.
     
    Last edited: Jul 21, 2016
  3. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    I was able to get a decent effect using these values with this setup:

    The main thing is that the Relative Velocity Threshold values are very low, so small movements cause PhysSound to play sounds. Also in order to get the impact sounds to play I had to set the Impact Normal Bias to 0. The sides of my drawer also were very flush against the inside of the desk model to actually get PhysSound to register the OnCollisionStay event. Hope this helps!

    The issue with OnTrigger events was an oversight on my part, sorry about that. I just realized the problem myself today while I was working on a project that uses PhysSound. A option for turning off trigger detection will be coming in the next update.

    I think I may have come up with a solution to the duplicate sounds problem you talked about too. It may also help with another problem I've had a report about that happens in instances like when a player pushes an object, but the slide sound doesn't play.
     
  4. KamiKaze425

    KamiKaze425

    Joined:
    Nov 20, 2012
    Posts:
    206
    Here's another question for you:
    How about something like an airplane flying? So using velocity or rotation to adjust the volume and pitch when it's not actually colliding with anything. Not sure if that's possible with your plugin currently, everything seems collision/impact based.
     
  5. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    You would be correct, my system only handles actual collisions via the OnCollision and OnTrigger events at the moment.
     
  6. thematic

    thematic

    Joined:
    Aug 8, 2016
    Posts:
    1
    hi, i'm interested in your plugin
    but before i purchase it, i would like to ask some questions

    would it possible for your plugin to generate sound in basketball game?
    for example ball driblling, ball impact with wooden board, ball impact with steel ring, ball going through the net etc?

    also i'm not familiar with Unity Assets store license. once i bought this asset, can i use it in all my projects without additional fees?

    Thanks!
     
  7. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    Yep, I think PhysSound will work great for your game! I will say, though, that PhysSound is meant more for general use cases that involve pure physics, and doesn't necessarily cover special cases (like animations for example). So that is something to keep in mind.

    Think of how in Half-Life 2, a game renowned for its physics, every object from barrels to crates to cans felt so much more real because of the sound design and audio engineering. This is what I hope to emulate with PhysSound.

    Funnily enough, I actually happen to have a few basketball sounds bundled in as a demo too.

    And for your second question, I'm not really qualified to answer it, but as far as I am aware you can use and modify any asset bought from the asset store however you want and use it in as many projects as you want. The only thing you can't do is redistribute it.
     
  8. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    Update incoming!

    v2.5.1 Updates:
    • Added 'Hits Triggers' option to PhysSound Objects, which can be used to turn on/off the trigger detection functionality.
    • Renamed "Temp Audio" to "Audio Pool"
    • Some performance optimizations
     
  9. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    69
    Hi @crazymonkay,
    I love the concept of Physsound very much, and bought it some time ago.

    I found out that there is one big performance concern which makes the asset unuseable for me on mobile (for which I'm building a heavily physics based game). I would love to be able to use Physsound for this project, but there is one bugged Unity event/hook you are using which creates about 1Kb of GC allocations every frame, for every colliding object(!).

    That actually increases my total GC allocations by about 10x up to 100x(!), creating constant frame jitters and wasted resources.

    The culprit is in short this Unity event/hook you are using:
    void OnCollisionStay(Collision c)

    One would expect using those hooks to be safe performance wise, but unfortunately this is an exception. OnTriggerStay(), OnCollisionEnter() & OnCollisionExit() are luckily not really problematic, but having a single OnCollisionStay() OR OnCollisionStay2D() -method in any active script, will result in this problem, even if the method is empty!

    Here is more info about the problem and confirmation from Unity that they are trying to make a workaround and release it eventually, but that hasn't happened yet.

    The only way I see I could use Physsound while the GC allocation problem persists in my current project is to get rid of the function ( OnCollisionStay(Collision c) ).

    TLDR:
    Would you consider it possible to get safely rid of OnCollisionStay() in PhysSoundObject.cs, maybe by replacing it with OnCollisionEnter() + OnCollisionExit() + a coroutine or something? What do you think :)?

    EDIT: Or replace somehow with OnEnterTrigger ? Or just add an option in the settings to not use OnCollisionStay(), moving it to another script-component, which can be activated/deactivated automatically.
     
    Last edited: Sep 23, 2016
  10. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    Hi ilmario,

    Sorry for the late reply. I have noticed this issue in the past as well.

    The OnCollisionStay event is mostly used for generating sliding / rolling sounds, so if your game does not need sliding or rolling sound effects this event can safely be removed entirely from the PhysSoundObject script. In fact, any of the Unity event hooks (OnCollisionEnter / Exit, OnTriggerEnter / Exit) can be safely removed if you do not need them. Simply delete the function (or comment it out if you prefer) and you're done!
     
  11. daniel-griffiths

    daniel-griffiths

    Joined:
    Jun 14, 2016
    Posts:
    27
    Hi there just got your asset and it looks great. I have a simple scene with a cube and using leap motion to interact along with Vive.
    I have the cube setup as the same as your plastic cube and i am getting a error:

    IndexOutOfRangeException: Array index is out of range.
    PhysSound.PhysSoundObject.OnCollisionStay (UnityEngine.Collision c) (at Assets/PhysSound/Scripts/PhysSoundObject.cs:300)

    Not quite sure where i am going wrong.

    Any pointers would be great.

    Thanks

    Daniel

    Also is there a 1,2,3 setup guide as the docs just cover what everything does.. no kind of get up and running guide.

    Thanks
     
  12. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    69
    Thanks for your comment. I'm aware I could remove them manually myself - though good to also hear that it woudnt break all functionality. However, I want to keep my assets updateable (not-hacked), and thus would very much prefer if your asset made it easy to skip using those problematic hooks. In this case the problem is not your code inside the
    OnCollisionStay()-hook/method, but the existance of the function which creates the performance hit.

    The hook(s) could be still used for those who dont care (with CPU cycles to spare, i guess), but if the hooks lived in another helper script, which could be included/disabled based on some global variable or such. That would be a really nice user experience.

     
  13. MetanautAndrew

    MetanautAndrew

    Joined:
    Nov 17, 2016
    Posts:
    5
    Hello there, I am very interested in getting this asset. I have read some of the comments regarding slow performance with a large number of concurrent collisions, and I am aware that is due to Unity's sound system.

    I would like to ask how much is "a large number", or how many concurrent collisions will start to cause a noticeable drop in framerate?

    (Background: We are building a physics based game that may have as many as 20-30 concurrent collisions)
     
  14. local306

    local306

    Joined:
    Feb 28, 2016
    Posts:
    118
    I think I came across a bug where the soft slide audio volume level wasn't resetting i.e.) it would stay at the original volume once reached.

    I'll DM you a build to check out.
     
  15. kbabilinski

    kbabilinski

    Joined:
    Jul 12, 2012
    Posts:
    15
    I know this might be out of the scope from the Asset but Could you give a walk though on how to trigger the events via code? I'm trying to use this asset in a game with Photon Networking and the network objects don't make a sound because their rigidbodies are either kinematic or constrained
     
    Banksy likes this.
  16. transparent-room

    transparent-room

    Joined:
    Mar 11, 2017
    Posts:
    1
    Hello, I stumbled upon PhysSound while looking for Audio Assets that would be more than just sample collections. Incidentally, the game we're about to release, has props that the user can grab and drop and toss around the room, and I asked the programmers if it was possible to measure the collision forces and play relevant sounds, etc. They said it was possible but quite a fuss, so we decided to leave those props silent. I wish I had discovered your system earlier :). I'm gonna give it a try though, and possibly implement it in an update for the game, in the near future.

    I have a question though, because I'm mainly a sound designer and not a programmer (I'm working on learning the basics so I can at least be in the loop). Let's say we have a moving object colliding with a stationary object (either impact or sliding), and both objects have PhysSound Materials and PhysSound Objects assigned to them. Will they both make a sound (assuming we have assigned sounds in the AudioSets of each) ? Or is it just the moving object that will make a sound?

    If the latter is true (and my understanding is that that's the case), is it possible to consider a feature addition so that the stationary object can make a sound too? Like, for instance, I have a knife that falls on the floor, but can also fall on top of a metal workbench. It would be nice if the knife made its own sound on impact (whether it's on the floor or the metal workbench), but also have the workbench resonate when the knife hits it, or the floor make a short impact sound, different if it's tile, or wood, etc. I suppose I can achieve that with using a dedicated, different AudioSet used in the case of the knife hitting the workbench, but I can see a lot more flexibility in having each object make its own sound and combine the two sounds on impact or sliding. (although tricky recording and sound editing procedures admittedly). Having sounds separate like that, would allow us to end up with a smaller number of recorded sounds, and then they would combine to produce a big variation of sounds heard, instead of trying to record every possible combination of objects hiting or sliding on other objects. Like, if we wanna get ultra detailed and realistic (and I like going down that path, haha), and we have 4 different objects hitting on 4 different surfaces, we have to use 4x4=16 different AudioSets. But if we can use 4 AudioSets (one for each moving object), and 4 AudioSets (one for each stationary object/surface), then with some clever sound design we can have 4+4=8 AudioSets, which is less resource-consuming (although double the AudioSources, admittedly). And while we're at it, it would be nice if (for the sliding sounds) there was an option for "release/trail" sounds in the AudioSet, considering that after the sliding has finished (I slide the knife and then lift it up), the workbench surface still resonates, and it would sound unnatural if it just stopped sounding.

    Ok, I realize I'm going a little too far and complicated here, but maybe these are some nice suggestions for a future update. This is great as it is, and thank you for going through the trouble of making it, and especially for offering it at such an affordable price. Btw, is this licensed per-seat, or do we buy one and the whole team can use it?

    Best Regards,
    TR
     
  17. MetanautAndrew

    MetanautAndrew

    Joined:
    Nov 17, 2016
    Posts:
    5
    Hello Road Turtle Games,

    We at Metanaut have been using your PhysSound asset and it has been very useful in adding immersion for our VR game.

    Through extensive use I have been wondering if you could help answer 3 of the issues we've been having:

    1. Template Audio Assignment
    I have prefabs that have the PhysSound Object script. These prefabs need to be instantiated in run-time, but in the prefab they won't have the "Template Audio" assigned to a sound source because the templates only exist in specific scenes. I would prefer not to use "Auto Create Sources" because I want to use the audio pool for optimization reasons. I also don't want to create an audio source component in each prefab so it can point to itself. Is there solutions to this where it can refer off of a template audio source that's also a prefab and can be in every scene at runtime?



    2. Impact Volume at minimum velocity

    From how I understand it, using the "Min" and "Max" of "Relative Velocity Threshold" while disabling "use Collision Velocity" and enabling "Scale Impact Volume" will result in the object playing a random sound in the impact clips list (which is desired), and will scale the impact volume depending on impact velocity (also desired).

    While it seems like if an impact is below the "Min" value, it won't play a sound (acceptable & useful), the sound that plays if the impact is just past the "Min" value is too quiet.

    From extensive testing and trial & error, it seems like if the impact velocity is at or near the "Min," the volume of the impact sound would be close to 0, making it way too quiet and not noticeable. This is not desired.

    I would like to be able to define the lowest volume level that would be played. For example, I would prefer that the quietest possible sound is at volume level "25" instead of close to "0". I would have no problem with setting max volume, as that can be done in the Audio Source template.

    Please let me know if there's a solution for this.



    3. Rolling (vs sliding) Sound

    One of our key Game Objects in the game are balls that roll around on tracks. While your asset does have a sliding clip function, it doesn't seem to play when a ball is rolling across a surface. It would be preferred if there's a function for playing a sound loop when the object is rolling over a surface.

    So far our experience with using the PhysSound asset has been great, and we are happy with our purchase. But the above issues are preventing us from using it to achieve full immersion. If you guys happen to have a beta version of the next update with these features above we would be happy to test for you.

    I look forward to hearing back from you.
     
  18. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    55
    Hi, crazymonkey!

    I have a quick question about PhysSound which I purchased a few days ago.
    As you see in the picture, my Sword1 (1) object has some different parts as its children. I would like to assign different collision and sliding sound for each part.
    The problem is that Sword1(1) has rigidbody component so PhysSound works when I attach PhysSoundObject component to it but I am able to give my sword only one set of sounds.
    When I attach PhysSOundObject to each part, then I got no sound because the children do not carry rigidbody component. They have their own colliders but they are controlled by their parent objects' rigidbody component.
    Is there any way to give different sound set to each part of my object with PhysSound? Give me any advise if you have any.

    Thank you,
    Gen
    ScreenShot20170520.jpg
     
  19. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    321
    Just purchased & am interested in generating skateboard sound effects.
    - Skateboard wheels rolling & sliding on a metal or wood half pipe.

    The skate wheels were created using Unity 5's Car wheel physics.
    Will this work ?
     
  20. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    321
    I don;t have an answer for this Q. but I'm also using Photon Networking so am interested n the reply
     
  21. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    Hi everyone! Sorry for the late responses on some of these, I haven't been keeping up with PhysSound support as much as I should.

    @Bravo101:
    By default there is no public API for playing sounds via code, outside of the collision messages, however the functions used within the PhysSoundObject script to play a sound are playImpactSound and setSlideTargetVolumes if you need to modify the script. I will potentially add a public API in a future update.

    @transparent-room:
    Static objects should play sounds when collided with as long as they have audio set(s) defined in their PhysSoundMaterial (and of course have an audio source).

    (I have already responded to @MetanautAndrew via email and have implemented his requested features in an unreleased version)

    @gisono:
    Currently PhysSound does not have this ability, as collision messages are sent only to the object with the Rigidbody component. However I have discovered that I may be able use Collision.contacts.thisCollider to get which child collider the collision was triggered from.

    @Banksy:
    Based on some tests I have done it seems that wheel colliders do not send the collision messages required for PhysSound to work, so unfortunately PhysSound is currently not compatible with wheel colliders.

    Hopefully the next update to PhysSound will be quite large. I have even considered revamping the entire system for a v3.0 update, though I am kind of reluctant to do so for backwards compatibility reasons (i.e. I don't want to break everyone's stuff :p)
     
    Last edited: May 26, 2017
    AntonioModer and Kagyu like this.
  22. Kagyu

    Kagyu

    Joined:
    Mar 5, 2016
    Posts:
    55
    Great news! I am really looking forward to see you implement this feature in the next update. If you need a tester, let me know. I will do it with pleasure.
     
  23. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    321
    Regarding the skateboard on a ramp... no big deal. i'll just have to improvise :) I've tried attaching a sphere to the back of the board with a spring constraint & it works fine.. The sphere has a rigid body attached.
     
  24. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,796
    Please count me in. And let me know how I can help you and your asset.
     
  25. alex55555

    alex55555

    Joined:
    Feb 18, 2014
    Posts:
    25
    Hi,
    I'm using PhysSound with a humanoid rag doll and I'm wondering if it's possible to limit the number of times an PhysSound audioSource is trigger over, say, 1 second.

    I want to avoid my character's feet triggering an impact sound twice, as this sounds weird. I just want the sound effect to be played once, for both legs.

    How should I go about this?
     
  26. CurtisMcGill

    CurtisMcGill

    Joined:
    Aug 7, 2012
    Posts:
    66
    We are using your package with VR and things work great. We have disabled on stay, on exit and all 2D stuff.

    Sometimes we get repeats sounds using vrtk, the onstay disabled and if we slide object over surface, it plays 10ish sounds at once.

    Can we limit the sounds/sec on each object? If you can point me in the direction to add a delay?
     
    Last edited: Oct 27, 2017
  27. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    138
    Is this product still supported?
     
    HenryChinaski and AntonioModer like this.
  28. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    91
  29. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    What happened to this asset? I was going to use this asset.
     
    AntonioModer likes this.
  30. HenryChinaski

    HenryChinaski

    Joined:
    Jul 9, 2013
    Posts:
    91
    It generally works but it was simply abandoned by the author, I believe.
     
    Crossway likes this.
  31. attaway

    attaway

    Joined:
    Nov 12, 2014
    Posts:
    35
    anyone know of an alternative?
     
    slimshader likes this.
  32. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    Hey guys,

    So after a long time of silence I owe you all some sort of comment on this.

    The simple reason is that I have not had time to seriously work on updating the package and be active in the forums (I still try to reply to emails, though). At this point it is not right for me to continue selling a mostly abandoned package so I have deprecated it.

    A while back I did start on a completely reworked system that set out to improve basically every part of PhysSound, but I have not been able to dedicate much time to that either. If I ever am able to complete that I will try my best to make sure those who have purchased PhysSound will get the new package at least at a significant discount.
     
  33. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    200
    attaway likes this.
  34. VirtualDawn

    VirtualDawn

    Joined:
    Sep 15, 2014
    Posts:
    13
    I'm pretty sad to hear this. PhysSound was excellent tool for our smaller VR projects: the tool really made VR interactions feel great and physical. I'm kinda astonished that rolling and sliding and sound by collision force aren't common features in audio packages like master audio.
    I wanted to encourage you to make that new version of PhysSound, I really think there is a good market for this with VR getting bigger every year.
     
    Last edited: Mar 20, 2019
    Deckard_89 and attaway like this.
  35. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    Hey guys,

    So after getting a few messages about how people still want to use PhysSound, I have decided to make it free. You can download the package here (I'm not bothering to put it back up on the asset store).

    If anyone wants to put the source up on GitHub I am also completely fine with that too.
     
    Last edited: Apr 8, 2019
  36. ScruffyRules

    ScruffyRules

    Joined:
    Feb 6, 2018
    Posts:
    1
    Thank you!
     
  37. TCL987

    TCL987

    Joined:
    Jun 17, 2017
    Posts:
    2
    Thank you.

    However can you clarify what the licensing terms are? Is it still under the Unity Store license? If so that would prohibit redistributing it on GitHub. If you want to let people distribute it as "open-source software" you need to release a version under a permissive license like the MIT License, the Apache License, or the Unlicense. Releasing a ZIP with the UnityPackage and a text file containing whichever license you prefer license would be enough.
     
    ScruffyRules likes this.
  38. crazymonkay

    crazymonkay

    Joined:
    Apr 1, 2013
    Posts:
    99
    Thanks for pointing that out, I've updated the download link to be a ZIP with an MIT license included. Everyone is free to redistribute the package as-is or with their own modifications (would be interesting to see what people have added/improved/fixed).
     
    tcmeric, VirtualDawn and ScruffyRules like this.
  39. OwlBoy-

    OwlBoy-

    Joined:
    Dec 11, 2015
    Posts:
    10
    Thank you @crazymonkay !

    The Great Pug in VRChat has used this for a few years and wouldn't be the same without it!
     
  40. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    279
    Hey, thanks @crazymonkay for making this available.

    Before I put this up on my own GitHub, is there anyone already working on it and looking for another contributor? @TCL987 ?
     
  41. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    168
    Hello, where can we contribute to this project?
     
  42. QQQ_QQQ

    QQQ_QQQ

    Joined:
    Jul 12, 2019
    Posts:
    6
    Thanks. Super job! :)