Announcement

Collapse
No announcement yet.

Component: SetIsReplicated(true) -- All variables also replicated?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Component: SetIsReplicated(true) -- All variables also replicated?

    I have a component derived from UStaticMeshComponent and in the constructor I have SetIsReplicated(true). Should this mean that if I have a variable int MyInt; declared in the .h that that integer will also be replicated?

    I'm having some issues that suggest it's not...

    #2
    No. SetIsReplicated(true) just says that a Component can be replicated. You still need to mark individual fields as Replicated and add them to the LifetimeProperties array.

    Code:
    // Header
    
    // Method override so we can tell the system about our property.
    virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const;
    
    // Mark this field as replicated.
    UPROPERTY(Replicated)
    int MyInt;
    
    // Source
    virtual void MyClass::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
    {
         Super::GetLifetimeReplicatedProps(OutLifetimeProps);
    
         DOREPLIFETIME(MyClass, MyInt);
    }
    More here: https://wiki.unrealengine.com/Replication
    Able Ability System - A high performance, robust ability system for UE4. Now Available!

    Comment


      #3
      Thanks very much, Matt. That makes sense

      Comment

      Working...
      X