playMaker

Author Topic: Trigger sound when objects crash into each other?  (Read 1748 times)

SpencerPDX

  • Playmaker Newbie
  • *
  • Posts: 22
Trigger sound when objects crash into each other?
« on: January 18, 2017, 04:21:11 PM »
Hello!

I've got a scenario in which a flowerpot gets knocked off a ledge and crashes to the ground far below. The flowerpot has a collider and rigid body, and the ledge and ground have colliders. The fall and physics work fine. I might eventually make the flowerpot explode upon colliding with the ground, but the most pressing problem at the moment is that it doesn't make a sound when it crashes.

Any suggestions on how to make this work? I suspect it has something to do with either the Collision Event action or the Get Collision info - some way of detecting the force of an impact and having that trigger a sound.

I can't of course have it make a sound when it's simply in contact with any other collider, because that would make it so the flowerpot sliding along the ledge before falling would make a crash sound. :) Unless, I suppose, I used tags to distinguish the ground and ledge...

Anyway, seems like a more direct solution that detects a magnitude of force must be available.

Any help would be greatly appreciated! 



SpencerPDX

  • Playmaker Newbie
  • *
  • Posts: 22
Re: Trigger sound when objects crash into each other?
« Reply #1 on: January 18, 2017, 04:48:36 PM »
This person seems to have basically the same soundfx need:

http://answers.unity3d.com/questions/361390/audio-play-when-object-hit-collision.html

That question's answer leads to this bit of script reference:

https://docs.unity3d.com/ScriptReference/AudioSource.PlayOneShot.html

Not entirely sure how to implement this (yeah, even with the reference, I can be kind of a dunce about scripting), so I guess the question is how might I go about doing this in Playmaker?