Parenting
Because the character is a rigidbody, it cannot use the parenting mechanic of the Entities package's transform system to make a character entity a child of another. Instead, it comes with its own parenting mechanism.
By default, the standard characters use this parenting mechanism internally to handle standing on moving platforms. The KinematicCharacterAspect.Update_MovingPlatformDetection
update step of your character determines if the GroundHit
is a valid candidate for a moving platform, and if so, it calls KinematicCharacterAspect.SetOrUpdateParentBody
in order to assign this hit entity as the character's parent. This is what makes the character move along with the moving platform.
If you want to manually control character parenting, you should first remove the call to KinematicCharacterAspect.Update_MovingPlatformDetection
from your character aspect's update so that this doesn't interfere with your own parenting code. Then, you must call KinematicCharacterAspect.SetOrUpdateParentBody
on every frame where the character should be parented to another entity. The reason why it must be called every frame is because when the character moves relatively to its parent, it must update its local position and rotation relatively to its parent. To remove the parent, simply call KinematicCharacterAspect.SetOrUpdateParentBody
again, but with Entity.Null
as the parentEntity
and default
as the anchorPointLocalParentSpace
. Once a parent has been unset in this way, it is not necessary to keep calling KinematicCharacterAspect.SetOrUpdateParentBody
every frame, because there is no local position and rotation to update.