0 支持
(200 ポイント)
現在VRゲームにMUNで通信をさせようとしています。

プレイヤーの同期はうまくいき、プレイヤーだけを動かしている状態なら通信は継続されるのですが、

敵NPCを出現させると、ルームに入室したほうがしばらくして切断されてしまいます。ネットワーク環境に問題はありませんでした。

環境は2台のPCを使って通信をやっています。

エラーの内容は以下の通りです。

エラー1:ルーム入室時に発生

InvalidCastException: Cannot cast from source type to destination type.

MonobitEngine.MonobitAnimatorView.Deserialize (MonobitEngine.MonobitStream stream) (at Assets/Monobit Unity Networking/Plugins/MonobitNetwork/MonobitAnimatorView.cs:196)

MonobitEngine.MonobitAnimatorView.OnMonobitSerializeView (MonobitEngine.MonobitStream stream, MonobitEngine.MonobitMessageInfo info) (at Assets/Monobit Unity Networking/Plugins/MonobitNetwork/MonobitAnimatorView.cs:143)

System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.

System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)

System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)

MonobitEngineBase.MonobitView+SerializeViewMethod.Read (MonobitEngine.MonobitStream stream, MonobitEngine.MonobitMessageInfo info)

MonobitEngineBase.MonobitView.DeserializeView (MonobitEngine.MonobitStream stream, MonobitEngine.MonobitMessageInfo info)

A.K.A (System.Object[] , MonobitEngine.MonobitPlayer , Int16 )

A.J.A (mun.STREAM.RoomRPCResponse& )

mun.MunClientSessionToRoomServer.OnReadRecordCallback (IntPtr pMunRoom, IntPtr connection_data, UInt32 seqnum, UInt16 options, UInt16 payload_type, IntPtr payload, UInt32 payload_len)

(wrapper native-to-managed) mun.MunClientSessionToRoomServer:OnReadRecordCallback (intptr,intptr,uint,uint16,uint16,intptr,uint)

mun.MunClient.FixedUpdate ()

エラー2:切断時に発生

Error from mun_room_server. status=KEEPALIVE_TIMEOUT(MRS_KEEPALIVE_TIMEOUT: Keepalive timeout)

UnityEngine.Debug:LogError(Object)

Mrs:mrs_console_log(MrsLogLevel, String)

Mrs:mrs_output_log(MrsLogLevel, String)

Mrs:MRS_LOG_ERR(String, Object[])

mun.MunLogger:MRSEXT_LOG_ERR(String, Object[])

mun.MunClientSessionToRoomServer:OnErrorCallback(IntPtr, IntPtr, MrsConnectionError)

Mrs:mrs_update()

mun.MunClient:FixedUpdate()

よろしくお願いします。

回答 1

0 支持
(3.9k ポイント)

> InvalidCastException: Cannot cast from source type to destination type.

http://www.monobitengine.com/doc/mun/contents/Component/MonobitAnimatorView.htm

なお、現時点の MUN では Trigger パラメータには対応しておりませんので、
Trigger を同期させたい場合には、代替として Bool パラメータ型などに置き換えてください。

該当するアニメーションの(Assets/Animation/ZombieAnime.controller)のキー「Attack」および「FallDown」について、TriggerからBoolに置き換え、walk03 -> death02 の Conditions を 「FallDown is true」に、walk03 -> attack01 の Conditions を「Attack is true」に書き換えます。

更に、Assets/script/ZombieScript.cs に記載されているアニメーショントリガーについて、
        animator.SetTrigger("FallDown");

        animator.SetBool("FallDown", true);
に、かつ
        animator.SetTrigger("Attack");

        animator.SetBool("Attack", true);
に書き換えてください。

(200 ポイント)
回答ありがとうございます。
ご指摘の通りにスクリプトを直したのですが、エラーが消えず、通信が切断されてしまします。ゾンビの同期がうまくいってないためエラーが重なり、通信が切断してしまうのでしょうか?
(3.9k ポイント)
切断される原因、エラーが消えない原因については原因を分解して考える必要があるかと思います。ひとまず以下の点を確認してみてください。

1. 敵NPCのMonobitAnimatorView を削除した場合どうなるか(MonobitAnimatorVIew の同期通信が送られなくなるためアニメーションの同期はしなくなりますが、それで切断されなければ MonobitAnimatorView および関連するアニメーションデータが原因です。)

2. 敵NPCの MonobitTransformView を削除した場合どうなるか(位置同期がしなくなりますが、それで切断されなければ MonobitTransformView および関連する移動制御が原因です。)

3. 上記 1, 2 のいずれでも切断が解消されなければ、敵NPC以外が原因です(通信処理を妨げるようなループ制御がある、通信処理が途絶えるくらいにマシンの負荷が高い、など)
(200 ポイント)
回答ありがとうございます。
上記の点を確認したところ、どちらとも通信が切れることはありませんでした。
そして、元の状態に戻したところ、通信が切れることはなくなりました。ありがとうございました。
...