Skip to content

Commit

Permalink
Fixed data writing when using multiple avatars.
Browse files Browse the repository at this point in the history
• Fixed an out of range exception when _GetAvatarBytes() was preparing an output array for any data avatar past the first one.
• Fixed issue with data writing to more avatars by resetting the player velocity between avatar switches.
  • Loading branch information
Nestorboy committed Aug 27, 2022
1 parent b8ede43 commit 2648083
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Assets/Nessie/Udon/NUSaveState/Scripts/U#/NUSaveState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public void _SetData() // Write data by doing float additions.
}
else
{
localPlayer.SetVelocity(Vector3.zero);
SendCustomEventDelayedFrames(nameof(_VerifyData), 10);
}
}
Expand Down Expand Up @@ -530,9 +531,9 @@ public byte[] _GetAvatarBytes()
for (int boneIndex = 0; byteIndex < avatarByteCount; boneIndex++)
{
ushort bytes = _ReadParameter(boneIndex);
output[byteIndex++ + avatarByteOffset] = (byte)(bytes & 0xFF);
output[byteIndex++] = (byte)(bytes & 0xFF);
if (byteIndex < avatarByteCount)
output[byteIndex++ + avatarByteOffset] = (byte)(bytes >> (ushort)8);
output[byteIndex++] = (byte)(bytes >> (ushort)8);
}

return output;
Expand Down

0 comments on commit 2648083

Please sign in to comment.