Conceitos de Autoridade
Tudo o que você precisa saber sobre os conceitos de Autoridade & Autoridade de Rede.
Autoridade
Algumas Classes só podem ser geradas no servidor, outras só podem ser geradas no Cliente, e há alguns que podem ser gerados no Servidor ou Cliente. O lado que a Classe é gerada é chamado de Autoridade.
Methods and Events Availability
Alguns métodos e eventos na API só estão disponíveis em um lado específico (Cliente ou Servidor), outros estão disponíveis apenas no lado que gerou o lado de autoridade):

Lado do servidor
Método ou eventos que só podem ser chamados pelo lado do servidor.

Lado do Cliente
Métodos ou eventos que só podem ser chamados no lado do Cliente.

Lado de Autoridade
Métodos ou eventos que só podem ser chamados pelo lado que o geraram.

Both Sides
Methods or Events which can only be called in any side.
tip
Todas as entidades criadas no Servidor serão automaticamente sincronizadas no Cliente. E.e. você pode acessar os métodos e obter todos os dados dele sem precisar sincronizá-los manualmente.
Da mesma forma, entidades criadas no Cliente só existirão para esse cliente, tentando enviar essas entidades para o servidor irá causar erros.
Autoridade de rede
Outro conceito importante no mundo nanos é a Autoridade de Rede. We have a "distributed network authority" concept, which means the work of calculating physics and AI (for example) are automatically assigned and distributed to the clients. In general, if an Actor is near an in-game Character, it's physics will be calculated by that player's device. O jogador que é responsável por calcular e compartilhar os resultados é chamado de Autoridade de Rede.
O jogador atribuído é automaticamente calculado pelo servidor e leva em consideração algumas coisas, este cálculo só é feito se o jogador estiver possuindo um caractere:
- A distância **** do personagem ao objeto
- If the Character is grabbing a Prop
- If the Character is handling a Pickable
- Se o personagem é dirigindo um veículo
- Se o Personagem apenas tirou algo
Em todos estes casos, o Jogador será automaticamente atribuído para ser a Autoridade de Rede desse objeto.
Sobrescrevendo a autoridade de rede atual
É possível substituir a atual Autoridade de Rede de uma entidade específica usando o método :SetNetworkAuthority()
.
caution
Nota: Alguns atores não são a rede distribuída. Isso significa que eles não serão atribuídos automaticamente nem serão capazes de fazer com que sua Autoridade de Rede mude. Você pode verificar se uma entidade está na Rede Distribuída com o método :IsNetworkDistributed()
.
Exemplos de ações que são executadas somente pela Autoridade de Rede desse Actor
- Física de Objetos sincronizados (incluindo ao chamar
:SetForce()
). - NPCs walking with
:MoveTo()
or:Follow()
.
Debugging Network & Network Authority
We've added a new option in the settings to Draw Network Debug information in the World, you can toggle it in the settings (Settings -> Debug -> Draw Network Debug), it will draw squares on each entity and traces representing their networked movement.
Entity Square Colors Meaning
The Square in the entities represent the state in the Network Authority and it's health.
Color | Meaning |
---|---|
BLUE | You are the current Network Authority of that entity. You are sharing sync data to the other players. |
WHITE | You are not the Network Authority and the entity is sleeping. The current Network Authority is not sending sync data because the entity is sleeping. |
GREEN | You are not the Network Authority and the entity is being synced in a good cadence (no lag). |
ORANGE | You are not the Network Authority and the entity is being synced in an ok cadence (small lag - < 100ms). |
RED | You are not the Network Authority and the entity is being synced in an bad cadence (big lag - > 100ms, maybe even with packet loss). |
Entity Trace Colors Meaning
The Traces in the entities represent the network data received from the server. If you are the network authority you won't see the traces. The arrow points from where the entity is currently in your machine and where it should be accordingly to the network authority.
Color | Meaning |
---|---|
GREEN | The entity is being synced in a good cadence (no lag). |
ORANGE | The entity is being synced in an ok cadence (small lag - < 100ms). |
RED | The entity is being synced in an bad cadence (big lag - > 100ms, maybe even with packet loss). |