Hello everyone.
I am trying to implement a simple callback in my C++ class. I already implemented the callback in Blueprints, but I want to translate the same system in CPP. I managed to load an FMOD Component and created and bound a delegate function too. The callback works, but it triggers the function on every beat.
How do I get a reference to the bar, beat, position, etc.? Getting these ints and floats is easy in Blueprints by calling the component event “On Timeline Beat”:
The closest function I found in the UFMODAudioComponent::OnTimelineBeat class is .Broadcast(), but it asks for inputs instead of giving me references to these numbers.
This is how my constructor looks:
AMyCPPActorClass::AMyCPPActorClass()
{
PrimaryActorTick.bCanEverTick = true;
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaticMesh"));
FmodAudioComponent = CreateDefaultSubobject<UFMODAudioComponent>(TEXT("FMOD Audio Component"));
FmodAudioComponent->SetEvent(myEvent);
FmodAudioComponent->SetAutoActivate(false);
FmodAudioComponent->OnTimelineBeat.Add(Callback);
FmodAudioComponent->bEnableTimelineCallbacks = true;
Callback.BindUFunction(this, TEXT("CppRotate"));
}
Maybe, I am implementing this system in the wrong way.
Thank you for reading my thread and for any advice.
Best!