Hi I’m converting Blueprint to c++ and i got Some problem.
In Blueprint, I could call component event in actor easley but in c++ I dont know how to call it.
how can i call component event in c++ Actor that owns it?
Hi I’m converting Blueprint to c++ and i got Some problem.
In Blueprint, I could call component event in actor easley but in c++ I dont know how to call it.
how can i call component event in c++ Actor that owns it?
You should be able to call the component function directly from the component instance.
replace UmyComponent & AMyActor names accordingly.
In custom component
in .h
UFUNCTION()
void MyCustomFunction(float passedParameter);
in .cpp
void UmyComponent::MyCustomFunction(float passedParameter){
}
in the header file of the actor you would need
UPROPERTY()
class UmyComponent * myCustomComponent;
example for a hypothetical cpp file of the actor
#include "myActor.h"
#include "myComponent.h"
// constructor
AMyActor::AMyActor(){
myCustomComponent = CreateDefaultSubobject<UmyComponent>(TEXT("my componenet"));
// call function when needed
myCustomComponent->MyCustomFunction(5.0f);
}