The code below crashes my editor, when it is run on a multiplayer setup.
Works perfectly on single player, but on multiplayer it crashes the engine with this error every time.
Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\Epic Games\UE_4.20\Engine\Source\Runtime\Core\Public\Containers/Array.h] [Line: 611] Array index out of bounds: 139 from an array of size 78
This Section in particular if I comment it out the crashes stop.
// Apply rotation to IK root bone.
FTransform& IKRootBoneTransform = Output.Pose[IKFootRootBoneCompactPoseIndex];
IKRootBoneTransform.ConcatenateRotation(DeltaQuat);
IKRootBoneTransform.NormalizeRotation();
Main code:
if (!FMath::IsNearlyZero(LocomotionAngle, KINDA_SMALL_NUMBER))
{
const FBoneContainer& BoneContainer = Output.AnimInstanceProxy->GetRequiredBones();
// Get bone indexes and verify they exist.
FCompactPoseBoneIndex IKFootRootBoneCompactPoseIndex =
IKFootRootBone.GetCompactPoseIndex(BoneContainer);
FCompactPoseBoneIndex PelvisBoneCompactPoseIndex =
PelvisBone.GetCompactPoseIndex(BoneContainer);
if (IKFootRootBoneCompactPoseIndex == INDEX_NONE ||
PelvisBoneCompactPoseIndex ==INDEX_NONE)
return;
// Prepare convert Quat and
BoneContainer.FComponentSpacePoseContext CSOutput(Output.AnimInstanceProxy);
CSOutput.Pose.InitPose(Output.Pose);
// Build our desired rotations for IK root bone and body.
FRotator DeltaRotation(EForceInit::ForceInitToZero);
FRotator BodyDeltaRotation(EForceInit::ForceInitToZero);
const float BodyAlpha = FMath::Clamp((Settings.BodyOrientationAlpha - 1.0f), -1.f, 0.f);
switch (Settings.YawRotationAxis)
{
case EAxis::X:
DeltaRotation.Roll = LocomotionAngle;
BodyDeltaRotation.Roll = LocomotionAngle * BodyAlpha;
break;
case EAxis::Y:
DeltaRotation.Pitch = LocomotionAngle;
BodyDeltaRotation.Pitch = LocomotionAngle * BodyAlpha;
break;
case EAxis::Z:
DeltaRotation.Yaw = LocomotionAngle;
BodyDeltaRotation.Yaw = LocomotionAngle * BodyAlpha;
break;
default:
break;
}
const FQuat
DeltaQuat(DeltaRotation);
// Apply rotation to IK root bone.
FTransform& IKRootBoneTransform = Output.Pose[IKFootRootBoneCompactPoseIndex];
IKRootBoneTransform.ConcatenateRotation(DeltaQuat);
IKRootBoneTransform.NormalizeRotation();