0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Unity Netcode: クライアント側でだけ位置がガガガと震える問題

Posted at

あるキャラクターの位置を同期する際に、サーバでは正常に位置が更新され、クライアント側では位置がガガガガっとシェイクするような見た目が起こるバグがあった。

割と複雑な構造なプロジェクトだったので気が付かなかったが、IsServerを入れれていなかったことが原因だった。

実際に起こったことをシンプルに書くと以下のような感じだった。

修正前

protected override void HandleCharacterEnter(BaseNetworkCreature character)
{
    obj.GetComponent<NetworkObject>().Spawn();
}

修正後

protected override void HandleCharacterEnter(BaseNetworkCreature character)
{
    if (IsServer) {
        obj.GetComponent<NetworkObject>().Spawn();
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?