Replication of custom Urho3D::Component


I’m trying to make a derivative object based on Urho3D::Component to be replicated over network.

How I do that is the following:

class RefFrame:  public Urho3D::Component
    URHO3D_OBJECT( RefFrame, Component )
    /// Register object factory.
    static void RegisterObject( Context * context);

    RefFrame( Context * ctx, const String & name=String() );
    virtual ~RefFrame();

    void setName( const String & name );

void RefFrame::RegisterObject( Context * context )
    URHO3D_ATTRIBUTE( "Name", String, name_, "", AM_DEFAULT );

And when I create the “RefFrame” component as either Scene::CreateComponent<RefFrame>( REPLICATED ) or Node::CreateComponent<RefFrame>( REPLICATED ) it is created. But there is no reaction on component attributes change.

Even when I explicitly call “MarkNetworkUpdate()” nothing happens. Inside “MarkNetworkUpdate()” the “networkUpdate_” field is always “true”.

And Component::PrepareNetworkUpdate() for this component is called only once and exits because of “networkState_->attributes_” is NULL.

What do I miss here?

Is the Node itself a replicated one?

Note that a replicated component created into a local node will not be replicated, as the node’s locality is checked first.

Does setName call SetAttribute?
It would in turn call OnSetAttribute, which contains a call to MarkNetworkUpdate().

Yes. It is replicated. I also tried to create component directly by Scene.

No I didn’t try calling SetAttribute(). What it does is

void setName( const String & name )
    name_ = name;

I’ll try calling “SetAttribute()”.

BTW, does it matter when exactly replicated components are created before/after connection?

Thank you!

This should not make any difference, as long as they are created by the server.