Confused Tick between C++ Parent and BP Child

I have a C++ class and a Blueprint Instance.
Parent Tick is not called in Blueprint Class, but C++ Class is called anyway.
This situation only occurs in Blueprint with C++ parent, but it does not happen in Blueprint with Blueprint parent.
How do I disable parent tick?


↑in blueprint, no call to Parent Tick↑


↑in C++ Parent↑

editor
↑both Blueprint Instance and C++ Parent are calling Tick, I only put Blueprint into the level↑

1 Like

You can check Engine\Source\Runtime\Engine\Private\Actor.cpp, AActor::Tick(). Here you can see that it calls

UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "Tick"))
void ReceiveTick(float DeltaSeconds);

Hence, it’s a different function, so your blueprint “tick” has nothing to do with AActor::Tick(), besides being called from it.

If you really need to override parent tick in blueprints, then you make something like

//header
UPROPERTY(EditDefaultsOnly)
bool bParentTickDisabled = false;

//cpp
void AMyActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    if(bParentTickDisabled)
        return;

    //some parent tick code
}

and set bParentTickDisabled in blueprint manually.

Another option would be

//header
UFUNCTION(BlueprintNativeEvent)
void MyTick(float DeltaTime);

//cpp
void AMyActor::Tick(float DeltaTime)
{
      Super::Tick(DeltaTime);
      MyTick(DeltaTime);
}

void AMyActor::MyTick_Implementation(float DeltaTime)
{
    //some parent tick code, that can be overriden in childs(including bp-childs) just like you expect it
}
3 Likes

hi there,
In child blueprints, if you want to make a call to event tick from parent, select event tick, right click and select “add call to parent function”. Same applies to “begin play” if needed.
That should work.

1 Like

That is literally the exact opposite of what the original posted asked about.

It turns out, many blueprint events are actually “hooks” more than “direct function overrides.” Thus, you can’t “override” functions in the same way in blueprint, that you can in C++. (It is possible to arrange things so that you do, in fact, have the ability to override in blueprint, but Tick isn’t one of those.)

If you don’t want parent Tick called, then either override in C++, or turn off actor ticking entirely for the actor. If you still need to do occasional work in the blueprint, perhaps arrange for a timer to call into the blueprint, inside Event Begin Play or somesuch.

2 Likes

Yes, sorry, I misunderstood the question. Thank you for clarifying.

Happens to all of us :slight_smile:

1 Like

Thank you for your answer, now I completely understand! :smile:

1 Like