# Terminating a body instance in skeletal mesh crashesh physics 

**URL:** <https://forums.unrealengine.com/t/terminating-a-body-instance-in-skeletal-mesh-crashesh-physics/2404815>\
**Category:** C++\
**Tags:** skeletal-meshes, unreal-engine, crash, Physics, question\
**Created:** [March 21, 2025, 1:59pm UTC](https://forums.unrealengine.com/t/terminating-a-body-instance-in-skeletal-mesh-crashesh-physics/2404815 "2025-03-21T13:59:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AurochFilip](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AurochFilip](https://forums.unrealengine.com/u/AurochFilip)\
**Post date:** [March 21, 2025, 1:59pm UTC](https://forums.unrealengine.com/t/terminating-a-body-instance-in-skeletal-mesh-crashesh-physics/2404815/1 "2025-03-21T13:59:27Z")

</div>

Hello,

There is a crash happening if we try to hide a bone in skeletal mesh with `EPhysBodyOp::PBO_Term`. What happens is that bone (and below bones), their body instances will be terminated. When we call terminateBody on a body instance, we reset its BodySetup to null and reset other things but we do not reset `InstanceBoneIndex` to INDEX\_NONE (`void FBodyInstance::TermBody(bool bNeverDeferRelease`).

If we were having ticks disabled on a mesh(deffered kinematic enabled, as by default for any mesh), remove a bone, and at any point start the tick on the mesh, Chaos Physics scene in `void FPhysScene_Chaos::UpdateKinematicsOnDeferredSkelMeshes()` will try to update that bone in its ParallelFor. The BoneSetup is null, and in

```auto
	if (!BodyInst->IsInstanceSimulatingPhysics())
				{
					const int32 BoneIndex = BodyInst->InstanceBoneIndex;
					if (BoneIndex != INDEX_NONE)
					{
						const FTransform BoneTransform = ComponentSpaceTransforms[BoneIndex] * CurrentLocalToWorld;

						TeleportActorsPool[ActorPoolStartIndex + i] = ActorHandle;

						// TODO: Kinematic targets. Check Teleport type on FDeferredKinematicUpdateInfo and don't always teleport.
						Body_External.SetX(BoneTransform.GetLocation(), false);	// only set dirty once in SetR
						Body_External.SetR(BoneTransform.GetRotation());
						Body_External.UpdateShapeBounds(BoneTransform);

```

as the BodyInst-\>IsInstanceSimulatingPhysics() returns false since `BodySetup` is null, and BoneIndex is not INDEX\_NONE, it will try to set values to Body\_External, but Body\_External is null. And thus the crash happens.

Is this a known issue, or is there something that I am doing in a wrong way that is not supported by skeletal mesh/physics?
