ECS Character Controller Parenting crashes Client Build

Hello, @philsa-unity

I have used the parenting mechanism of ECS CC, and it works well with ghost entities that do not have a PhysicsBody or KinematicCharacterBody. However, when I make a character (CC) a child of another entity (e.g., a Horse) where both have KinematicCharacterBody components, the Client Build crashes.

 if (allowMovingPlatformDetection)
 {
     if (context.PlayerSummonersLookup.HasComponent(ThirdPersonEntity))
     {
         var parent = context.PlayerSummonersLookup[ThirdPersonEntity].Summoner;

         if (parent != Entity.Null)
         {
             var positionEntity = context.ChildLookup[parent][0].Value;
             var AnchorePoint = context.LocalToWorldLookup[positionEntity].Position;
             CharacterAspect.SetOrUpdateParentBody(ref baseContext, ref characterBody, parent, AnchorePoint);
         }
     }
     else
     {
         CharacterAspect.SetOrUpdateParentBody(ref baseContext, ref characterBody, Entity.Null, default);
     }
 }

Is it possible to achieve this setup without causing crashes?

How can I make parenting for 2 Character Controllers?

Any help appreciated.

Thanks.

Do you have the log when it crashes? Here’s where to find it: Unity - Manual: Log files reference (under the " Player-related log locations" section

We’d have to see if there’s a useful error in there that could help us figure it out. There’s a few ways errors could happen based on this code snippet:

  • baseContext wasn’t properly constructed and therefore has invalid TrackedTransformLookup (used inside the CharacterAspect.SetOrUpdateParentBody function)
  • context.PlayerSummonersLookup or context.ChildLookup or context.LocalToWorldLookup aren’t properly assigned/constructed
  • parent doesn’t have a Child component or its Child buffer has 0 length (line 9)
  • positionEntity doesn’t have a LocalToWorld component (line 10)

…or maybe something else I’m not seeing at the moment

1 Like

Thank you for response. Yes, I have used “HasComponent” and it solved the problem.