How to Make Audio Come From a Character or Game Object?

Cr4shBarcode 8 months ago in Behavior updated 8 months ago 5

I am making an enemy that will follow the Player around the level and taunt him. I put an Audio Source component on his head. But when I go to use the "Play Sound 3D" action, there are options to attach audio to the Player, a position, and Invoker (not sure what that is), a transform, and a bunch of variables, but I can't see how any of that will help me attach the sound to a moving character who is not the Player. What should I do?

Unity version:
Game Creator version:

You don't really need GC Actions for this. On the Enemy, put the Audio source and set it to 3D - you will be to play with the 3D settings, probably reduce them.

The man camera has the Audio Listener, so whenever the camera is close to the enemy, you will hear the sound. Depending on what camera motor you are using, you might want to move the audio listener to the player, but you can only have one audio listener per scene.

Hope this helps.


What Paul says is correct. However, the Play 3D Sound Action, as you mentioned, has a list of targets. These targets that you have enumerated, will define where the sound comes from.

For example, if you select Player, the sound will be played where the Player is and it will come from there. If you want to play a sound from any other arbitrary position, you can choose Transform. Transform is a component that defines a position, rotation and scale in space and is found in any game object in the scene. Simply drag and drop the object you want the sound to come from and voilá!

I’m following the Behavior Module tutorial, and I’m at the part where they use a behavior tree to make the character “talk” to the Player, and they use actions for this. I want to do the same thing, except I want to use audio clips instead of text messages. So I am indeed working with actions.

Perfect then. However, there's a quirk here. The Behavior module is a scriptable object and can't reference scene objects. In order to reference a scene object you'll need to use the Blackboard and make use of a Local Variable to play a sound in the scene. This is explained in the tutorial, but I thought it was worth mentioning.


So you’re saying that I need to complete the steps of the tutorial, but when it comes to the messages part, I can substitute “Play 3D” sound, use “transform” in the options, and then drag and drop the item that the sound will come from into the input box. I’ll try it! Thank you.