Hello Everyone.
I would like to trigger a precise Matinee from a branch of an if statement inside my player class method. Is there a way to do it? if so can someone explain me how it works?
Thank you.
This is my method where I would trigger the Matinee:
void AFirstDemoCharacter::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL))
{
if (bActionPressed)
{
if (OtherActor->IsA(AButton::StaticClass()))
{
if (!Cast<AButton>(OtherActor)->GetActive())
{
Cast<AButton>(OtherActor)->ToggleBActive();
// trigger Matinee here
}
}
}
}
}
I have already seen that but what I am asking is if I can even trigger an event on the level blueprint at that part of my code so I can play the Matinee from there. Thank you for the answer anyway.
Then, you can do this in your C++ code (where you put the “// trigger Matinee here” comment) to call it :
OnReadyToDoMatinee.Broadcast(0.0f);
Note that this is an example delegate for an event with 1 parameter (a float). There is macros in Unreal to do one without parameters, or multiple one. Search the code for DECLARE_DELEGATE for more info.
The next step is, in your Level Blueprint, have a reference to the object on which you did the previous code (in your case, AFirstDemoCharacter, so in your case I’m guessing
Get Player Character
Cast to AFirstDemoCharacter
Assign OnReadyToDoMatinee
That last part is the important one, it will bind an event to OnReadyToDoMatinee delegate of your C++ class.
You should now have an event node (red) that will be called whenever you call “OnReadyToDoMatinee.Broadcast(0.0f);”