Gett Component Through in c++

If you’re like me and did all the component set up via c++ its rather straight forward to get the component from the replicator.

In replicator .h I am forward declairing this, although I dont think you need the class but I did any way to be extra safe.

class USceneComponent* Root;

In replicator .cpp you set the component in begin play instead of blueprint and pass around the pointer. Just gotta Match what ever you named it in the GoKart.

Root = Cast(GetOwner()->GetDefaultSubobjectByName(TEXT(“Mesh Offset”)));

I used on screen debugging at the end of client tick to make sure I got the right component:

(Root == nullptr) return;
FString RootName = Root->GetName();
GEngine->AddOnScreenDebugMessage(-1,5,FColor::Emerald, FString::Printf(TEXT(“Root Name: %s”), *RootName));


Privacy & Terms