Download

Childclass not replicating like it's parentclass

Hello,

I bult a hierarchy in C++ as follows:

_______ ACharacter* (Unreal Character class)*
____________ |
________ ARobotBase (replicates fine)
_________ /______ *
ARobotMobile____ ARobotStatic
(both don’t replicate movement??)* :frowning:

Objects of type RobotBase replicate just fine, but objects of type RobotMobile or RobotStatic don’t replicate their movement. All objects override and call Super:: on following virtual functions:

  • BeginPlay()
  • Tick( float DeltaSeconds )
  • GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps)
  • SetupPlayerInputComponent(class UInputComponent* InputComponent)

and in their constructors: ARobot_Mobile::ARobot_Mobile(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {}

I hope my explanation is clear and allows somebody to spot my mistake!
Thanks a million.

Sincerely,
Tommie.

This might help (you need to override virtual bool ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override;)

Thanks, I am trying that now not really succeeding yet, as i’m not sure where to add this. Since ARobotMobile and ARobotStatic are both child classes of ARobotBase, shouldnt this all work out of the box? I was never required to add these functions to ARobotBase.

I added:

to ** RobotBase.h RobotMobile.h RobotStatic.h ** i added:
*virtual bool ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags RepFlags) override;

and to** RobotBase.ccp RobotMobile.ccp RobotStatic.ccp** i added:
*bool ARobotBase::ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags RepFlags)
{
return Super::ReplicateSubobjects(Channel, Bunch, RepFlags);;
}

but this does not seem to solve the problem. I am not entirely sure if what i am trying to do is correct though.