Attempting to start up the audio bus in Lua

0

I am trying to learn how to start using the audio bus in Lua. I have everything I need set up from wwise and the audio editor and everything works fine through the flowgraph. I am just running into issues on how to get it set up in Lua. If I uncomment out the top line the editor crashes to desktop. I'm sure there is something I am missing or something simple I am just wrong on as I have never tried setting this up before. Am I even close?

Here is the gist of what I have:


speechtest = {
Properties = {
testMessage = "Testing properties function of script",
}
}
function speechtest:OnActivate()
-- Setting up the audio bus
--self.audioTriggerComponentRequestBusHandler = AudioTriggerComponentRequestBusHandler();
self.audioBusId = self.audioTriggerComponentRequestBusHandler:GetCurrentBusId();
self.audioTriggerComponentRequestBusSender = AudioTriggerComponentRequestBusSender(self.audioBusId);
self.audioTriggerComponentNotificationBusSender = AudioTriggerComponentNotificationBusSender(self.audioBusId);
end
asked 7 years ago229 views
8 Answers
0
Accepted Answer

So I got it to work with the line I added previously and listed below

AudioTriggerComponentRequestBus.Event.ExecuteTrigger(self.entityId, "Button3");

For whatever reason I had to delete the lua component and re-add it and load the lua again and it just started working.

answered 7 years ago
0

I'me trying to get some help for you on this from a tech.

answered 7 years ago
0

Try to simply put an audio trigger component on a new entity and in a script in the same entity just call AudioTriggerComponentRequestBus.Event instead of Broadcast and pass in the entityId when you execute the trigger.Or just select the trigger in the ui and mark it to play immediately in the component.If it works come back to your original entity and try again call your function you then have to hear at least the trigger in the new entity you have tested before.

I didn't understand why do you need broadcasting in the first place...however if your audio trigger component is audible...it is supposed to work.

I also doesn't understand why you listed the line where you connect to AudioTriggerComponentNotificationBus.Connect(self,self.entityId).

It is not related to the AudioTriggerComponentRequestBus in the way I think you believe as it get just he notification for trigger executed in a component in this very entity.

answered 7 years ago
0

when bus are not attached to any listener they are just being ignored.

Do the AudioTriggerComponent added to your entity play when set to play immediately from the component gui?

I'm doubting you are setting the entityId to an entity without the Trigger Component are you sure you have a working trigger component and are targeting it in your event call?.

answered 7 years ago
0

OK so I decided to update to 1.8 from 1.7 and the syntax has changed quite a bit. So here is what I now have but I get the following error

[Error] Create Handler called on a non-reflected class. Please reflect an appropriate EBusHandler into the BehaviorContext in order to successfully create the EBusHandler.---------- START STACK TRACE ---------- =C: Connectscripts/speechtest.lua(27): ? ---------- END STACK TRACE ----------


	-- Setting up the audio bus
self.audioTriggerConponentRequestBus = AudioTriggerComponentRequestBus.Connect(self, self.entityId);
answered 7 years ago
0

I made it a bit further and no longer get any errors when running the script. However I am still unable to get any sound to actually play. Here is a basic version of what I have atm: I do have a UI set up that works just fine but I cut out that part and left in the parts in question for this post. Hence the "OnAction". The UI and the audio work just fine through FG just not through here.


local speechtest = {
Properties = {
PathToJson = "This is not used yet",
}
}
function speechtest:OnActivate()
 -- Setting up the audio trigger bus
self.audioTriggerComponentNotificationBus = AudioTriggerComponentNotificationBus.Connect(self, self.entityId)
end

	function speechtest:OnAction(entityId, actionName)
-- This will play the emergency response recording when button 3 is pressed
if actionName == "Click3" then
AudioTriggerComponentRequestBus.Broadcast.ExecuteTrigger("Button3");
return
end
end
answered 7 years ago
0

Tis certainly possible that I just made it wrong. Today is my first time using the 1.8 update with the lua. I substituted the following for the broadcast to no avail

AudioTriggerComponentRequestBus.Event.ExecuteTrigger(self.entityId, "Button3");

I get no errors at all but no audio plays. I can test the triggers without issues in the audio controls. Perhaps I am using the wrong entity? Hard to say at this point, since there are no errors I have nothing more to go on.

answered 7 years ago
0

Excellent! Glad you all were able to work it out. Thanks for posting the solution.

answered 7 years ago

This post is closed: Adding new answers, comments, and votes is disabled.