Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

UE4 C++ Wwise integration

+1 vote
Hi guys,

I've been using Wwise for about 3 years so far. Mostly I worked with UE4 through Blueprints integration.
At this moment I'm trying to integrate and use Wwsie in UE4 through C++.

I've followed the documentation and completed the basics of Wwise C++ integration:

https://www.audiokinetic.com/fr/library/edge/?source=UE4&id=using_cpp.html
also:
https://alessandrofama.com/tutorials/wwise-ue4/integration-setup
https://alessandrofama.com/tutorials/wwise-ue4/events/#Posting_Wwise_Events_by_writing_C_code_in_Unreal_Engine_4

Now, I'm trying to Post Event in my "character.cpp" but I don't know how to do it. I could not find that information on Wwise documentation.
Could you help me to go through with Wwise Post Event integration in UE4 using C++?

Thank you for your time reading my question.
I'm looking forward to hearing from you.

Sincerely,
Ara
asked Nov 2, 2020 in General Discussion by Pandemius (120 points)

1 Answer

0 votes

Hello Ara, 

How does your script look? How are you trying to post the event? 

For comparison with your script, here's an example of how you could post your Event in BeginPlay(). 

void ACustomActor::BeginPlay() {
     Super::BeginPlay();   
     UAkComponent* AkComp = NewObject<UAkComponent>(this);
     RootComponent = AkComp;
     UAkGameplayStatics::PostEventByName("Play_MyEvent", this, true);
}

To get here, I created a new C++ class Actor and dragged it into the scene. 
Alternatively, you could post an Event like this...

void ACustomActor::BeginPlay() {
    Super::BeginPlay();
    UAkComponent* AkComp = NewObject<UAkComponent>(this);
    RootComponent = AkComp;
    FOnAkPostEventCallback nullCallback;
    UAkGameplayStatics::PostEvent(Event, this, int32(0), nullCallback);
}

... and then in your header file add this ... 

public:
    // Sets default values for this actor's properties
    ACustomActor();

    UPROPERTY(EditAnywhere, Category = "Wwise")
    class UAkAudioEvent* Event;

... which would create a nice Event property under Details, like this: 
https://drive.google.com/file/d/1U2hfz9LBEkBbJ1O0vQnHskc4T2_0Dq_h/view?usp=sharing

Let us know if this is helpful.

answered Nov 3, 2020 by Mads Maretty S. (Audiokinetic) (38,280 points)
...