Most components do not replicate. Most gameplay logic is done in the Actor class and components usually just represent smaller pieces that make up the Actor.
Components replicate as part of their owning Actor.
对Component的replication来说,主要是两类Components:
- Static Components
- Dynamic Components
静态Components是随Actor的Spawn一起产生的,即在Actor的构造函数里创建的。当Components的Owning Actor在client或server上创建时,这些components就一起被创建出来了,不管这些Components被标记为replicated与否。
这个意思其实就是:标记为Replicated的Actor在Server端创建出来时,其会同步这个Spawn动作到所有client端,导致client端也会创建出一个Actor,而Static Components属于Actor的创建的一部分,自然会在Actor的创建过程中被创建出来。
说静态Components的同步,其实指的是其属性或事件等的同步,其自身都是随各自的Owning Actor的构造过程被创建出来的。而不是说:Actor在server端创建一个Actor的空壳子,然后通知clients也创建一份Actor的空壳子,再server端创建一个component,通知clients也创建一个components!不是这样的。