Unity-Technologies / CharacterControllerSamples

Sample projects for the Unity.CharacterController package
Other
225 stars 41 forks source link

OnlineFPS Demo: Error Triggered upon Character Death #5

Open MetaAlms opened 3 months ago

MetaAlms commented 3 months ago

MacOS: 14.2.1 Unity: 2022.3.20f1 Character Controller: 1.1.0-exp.10 Entities: 1.1.0-pre.3 Entities Graphics: 1.1.0-pre.3 Netcode for Entities: 1.1.0-pre.3

OnlineFPS Demo: If the character dies, trigger an error. Hope to fix it in the upcoming update. Thank you very much! Error message:

截屏2024-03-06 10 41 22 截屏2024-03-06 10 41 47 截屏2024-03-06 10 42 09 截屏2024-03-06 10 42 23

ArgumentOutOfRangeException: sub array range 0-2 is outside the range of the native array 0-1 Parameter name: length Unity.Collections.NativeArray1[T].CheckGetSubArrayArguments (System.Int32 start, System.Int32 length) (at /Users/bokken/build/output/unity/unity/Runtime/Export/NativeArray/NativeArray.cs:752) Unity.Collections.NativeArray1[T].GetSubArray (System.Int32 start, System.Int32 length) (at /Users/bokken/build/output/unity/unity/Runtime/Export/NativeArray/NativeArray.cs:763) Unity.Rendering.EntitiesGraphicsSystem.UpdateAllBatches (Unity.Jobs.JobHandle inputDependencies) (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-pre.3/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:1951) Unity.Rendering.EntitiesGraphicsSystem.UpdateEntitiesGraphicsBatches (Unity.Jobs.JobHandle inputDependencies) (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-pre.3/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:1227) Unity.Rendering.EntitiesGraphicsSystem.OnUpdate () (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-pre.3/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:1327) Unity.Entities.SystemBase.Update () (at ./Library/PackageCache/com.unity.entities@1.1.0-pre.3/Unity.Entities/SystemBase.cs:418) Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at ./Library/PackageCache/com.unity.entities@1.1.0-pre.3/Unity.Entities/ComponentSystemGroup.cs:723) UnityEngine.Debug:LogException(Exception) Unity.Debug:LogException(Exception) (at ./Library/PackageCache/com.unity.entities@1.1.0-pre.3/Unity.Entities/Stubs/Unity/Debug.cs:17) Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at ./Library/PackageCache/com.unity.entities@1.1.0-pre.3/Unity.Entities/ComponentSystemGroup.cs:728) Unity.Entities.ComponentSystemGroup:OnUpdate() (at ./Library/PackageCache/com.unity.entities@1.1.0-pre.3/Unity.Entities/ComponentSystemGroup.cs:681) Unity.Entities.SystemBase:Update() (at ./Library/PackageCache/com.unity.entities@1.1.0-pre.3/Unity.Entities/SystemBase.cs:418) Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at ./Library/PackageCache/com.unity.entities@1.1.0-pre.3/Unity.Entities/ScriptBehaviourUpdateOrder.cs:523)

MetaAlms commented 3 months ago

May I create a new entity with a 'RespawnMessageRequest' component to handle the local world UI and destroy the 'receiveRpcCommandRequest' entity at the end of the HandleRespawnScreen function? I found that it works for that problem.

https://github.com/Unity-Technologies/CharacterControllerSamples/blob/cbf6e6e628e7baaa8a39d7098a88c658d433df20/OnlineFPS/Assets/Scripts/GameManagement/ClientGameSystem.cs#L287

such as: // Send request to get processed by UI system //ecb.AddComponent(entity, new MoveToLocalWorld());

        // Show respawn screen
        Entity respawnScreenRequestEntity = ecb.CreateEntity();
        ecb.AddComponent(respawnScreenRequestEntity, new RespawnMessageRequest { Start = respawnScreenRequest.Start, CountdownTime = respawnScreenRequest.CountdownTime });
        ecb.AddComponent(respawnScreenRequestEntity, new MoveToLocalWorld());

        ecb.DestroyEntity(entity);