Melee Sword sound switch on/off

Silver100

Member
Hi,

Hope you can help,

Followed the documents on audio states sound but couldn't get to work how it describes? Trying to figure a simpler way so Melee Slash only plays with sword equipped, then turns off when not equipped. I usually use coliidders triggers for most of my events and audio sounds but was struggling figuring a disable audio when unequipped. At the moment I have devised a basic system. Works well to a point.
My character has only 3 equip states;

Rifle
Sword
Unequip

I have collider attached to rifle and sword tagged swordequip and rifleequip. They both enable relevant sounds

Rifle has audio fire sound, then the sword collider deactivates rifle sound applys sword slash 1, but after sword nothing can turn off sword sound.
 
The use audio is specified within the Play Audio Clip module under the Usable Action Module Group. Is this where you set it? Have you tried comparing your Melee Action to that of the sword within the demo scene?
 
In the demo scene the usable action group appears to be empty (on the sword) unless I am looking the wrong place. I have carefully gone through all other areas in the demo scene and checked sword prefab modules no audio. Collision module contains box collider but no sign of audio? Not sure where the sword sound is coming from in the demo scene
 
In the demo scene is coming from this module with the MeleeSlash Audio Config:

1682590402735.png
 
Is there a way to click on the character in the scene. Does not apear until the game starts struggling to find the sword belonging to atlas I think I may be looking at the wrong sword?
 
Thanks, located was looking in the wrong place. I'm still not able to get to work as detailed below;

In the demo the prefab sword for Atlas is called 'SwordWeapon'. So using this as a guide

Clicked on the swords animator component (Where you see the animator id etc)

Scroll down to Melee action script

Look at modules beneath

Useable action module click the add / plus sign

add generic effects

effect group click +

Play audio clip

Now add melee slash in audio config box.

On generic audio clip change to -1

None of these steps work in my scene.

For some reason I'm just getting no output. My other idea with colliders seems an ideal quick reliable work around. I can get the sword audio just on trigger exit not working. If I could somehow get an object to appear and deactivate audio at the right time. Or have audio totally stopping after 3 clicks using a variable counter method (like a health counter) I'm just not good at rearranging code but that could possibly work well too.
 
Last edited:
Or being able disable fire /sword audio button when not equipped is what I'm really trying to achieve here. Some type of boolion I think but I'm not good at understanding those at the moment
 
On the surface that looks correct, but have you watched this section of the melee video? It shows visually what to do to add audio:

 
Thanks, yes I followed the guide a few times matching all fields etc in case I was missing something still not working. What's unusual is I can get my equip/unequip sounds just not any of the module attack sword slash sounds through following the process. I'm not sure how the whole audio process is triggered though to be able to fix. I'm using the recommended version of Unity too. It looks like It really should work. I would Imagine these must be either bool code/variables based or perhaps collider detection.
 
Last edited:
I just went through that section of the tutorial and it worked on my end. Have you tried comparing the audio module that you have created versus the one in the demo scene that works?
 
Yes compared with the demo audio module settings the only thing I can think I'm doing different is I'm not using any combinations or combos in my scene. I may be wrong but just guessing here, I think in the demo the sword is set to audio combos. Can an audio clip just simply be attached to a single animation instead in the state machine/or scripted along side somehow to play on awake?
 
Last edited:
The combo aspect shouldn't matter as audio is setup separately. You could create a new animation event that calls a script that plays the audio when that event occurs. In this situation it would completely be outside of the character controller.
 
Thanks I've have now got a simple on trigger exit collision method working well on melee audio swipe sound. When the tip of the sword (with a game object tagged with a trigger collider) exits a separate game object collider, melee slash sound is made, and now sound is produced only when equipped. Works well for now, but could be tricky further down the line as more audio gets added. I'm sure I will get the character controller audio weapons audio module working eventually. Creating a new scene &/ project and duplicating from scratch often resolves.
 
Last edited:
Top