Forum rules - please read before posting.

3d sound play on hotspot highlight

edited February 2018 in Technical Q&A
Hey all - 

I'm wanting to have my game be a little more accessible from an audio standpoint for gamers without sight and would love to have a method of playing a 3d sound on a hotspot when it becomes highlighted.  Having a one shot sound would be great, but having the ability to have a sound start/fade in, loop as it's highlighting, and then stop/fade out when it stops being highlighted would be ideal.

My preference would be to have a default 3D sound set for the game globally so I don't have to attach a sound to every single hotspot in all of my scenes.

Anyone know if/how this would be possible?

Comments

  • A Hotspot's Highlight component can be made to trigger events when the effect begins and ends, but if all Hotspots are involved then it's a lot easier to use the OnHotspotSelect and OnHotspotDeselect custom events.

    (More on custom events can be found in the "Custom events" chapter of the Manual, as well as this tutorial)

    You could rely on an entirely custom script, but here's a way that should work with Actions and a minimal reliance on scripting.

    Create a new Sound object, assign the AudioClip and attach this script:

    http://pasteall.org/832381/csharp

    This script will have it automatically trigger ActionList assets whenever a Hotspot is selected/deselected.

    Also attach a Constant ID component, check Retain in prefab? and make it a prefab.

    Then create two ActionList asset files that each have a Sound: Play Action to affect this Sound - one to fade it in, one to fade it out.  Assign them in the script's Inspector, update the prefab, and add to each scene in your game (best test with just one first though)
  • Holy crap, Chris.  This is awesome!

    Looks like the action method only works with 2d sounds, but I think I can make this work with a couple of other ideas.  

    Very cool.  Thank you, sir!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!