Hi, I would like to have a BlueprintImplementable function, with which I can execute a BP-Function from C++.
I created a C++ class and based on that a BP Class and attached both to an actor. The classes are USceneComponents.
In the header one function with the property BlueprintImplementable. With an Event I want to inform the C++ class that a Mouse Button was clicked, then this should call FunctionBI and do something in the BPlueprint class.
void EventForMouseClicked();
UFUNCTION(BlueprintImplementableEvent, Category = "MyCategory")
void FunctionBI();
Lets assume I have a simple print Hello in the BluePrint with the overriden FunctionBI.
First issue I have: If I try to do it like this:
MyClass::EventForMouseClicked()
{
FunctionBI();
}
nothing happens.
If I put it into TickComponent
void MyClass::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
FunctionBI();
}
It executes it forever. So basically the C++ - Blueprint Connection is there.
If I try now to set a variable in order to ensure it doesnt execute always:
MyClass::EventForMouseClicked()
{
isClicked=true;
}
void MyClass::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if(isClicked)
{
FunctionBI();
isCLicked=false;
}
}
also it doesnt work.
THen I tried to log what kind of value isCLicked has. And there I was surprised:
I have always 2 times a value in the log:
Log: false Log: falseLog: false
Log: false
Log: true
Log: false
and of course the BluePrint function is not executed.
So my questions would be:
Why do I have 2 ticks(?), and why is only one of the variables changing?
Am I doing something wrong (obviously) as it seems nobody ever encountered this
Thanks in Advance