Hi,
I am currently working on an ActorComponent for my ThridPersonCharacter, that implements new movementtypes, such as wallrunning and so on.
In the component I get a reference to the charakter, that the component is attached to and add delegates for the events Character->OnActorHit and Character->MovementModeChangedDelegate.
All the methods and movements in my component work, when I play. Only these to delegates are not beeing called.
Here the definition in the .h File:
void HandleMovementModeChanged(ACharacter* Char, EMovementMode PrevMovementMode, uint8 PreviousCustomMode);
void HandleActorHit(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit);
I add them in the BeginPlay function:
Character->OnActorHit.AddDynamic(this, &UWallRunComponent::HandleActorHit);
Character->MovementModeChangedDelegate.AddDynamic(this, &UWallRunComponent::HandleMovementModeChanged);
I put a DebugMessage at the start of each function, but the messages are never displayed, because the function is never called.
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT(“MovementModeChanged”));
Because I couldn’t figure out the problem, I implemented a workaround. I exposed the two functions to the blueprint and hooked the events up from there. When I call the functions from the blueprint everything works fine. Of course I don’t want to keep this solution. Any help would be much appreciated. I am using Unreal Engine 5.