LabAPI
LabAPI copied to clipboard
[BUG]: Ragdoll.UnFreeze() applies relative rotation twice and wipes OwnerHub reference
Before You Report
- [x] I have searched for existing reports of this bug, and this bug report is unique.
Version
1.1.7
Description
Calling ragdoll.UnFreeze() creates a new ragdoll with a distorted/scrambled rotation and drops the OwnerHub reference (it becomes null).
To Reproduce
- Spawn or locate a player ragdoll.
- Call
ragdoll.Freeze(). - Call
ragdoll.UnFreeze(). - Observe that the ragdoll orientation is twisted incorrectly and
ragdoll.Owneris now null.
Expected Behavior
The newly spawned ragdoll should match the exact world rotation and preserve the original OwnerHub.
Additional Information
In LabApi/Features/Wrappers/Players/Ragdoll.cs line 310:
Base = RagdollManager.ServerCreateRagdoll(data.RoleType, data.StartRelativePosition.Position, data.StartRelativeRotation, data.Handler, data.Nickname, data.Scale, data.Serial);
In base game RagdollManager.ServerCreateRagdoll:
public static BasicRagdoll ServerCreateRagdoll(RoleTypeId role, Vector3 position, Quaternion rotation, DamageHandlerBase handler, string nickname, Vector3? scale = null, ushort? serial = null, ReferenceHub owner = null)
{
...
Quaternion relativeRotation = WaypointBase.GetRelativeRotation(relPos.WaypointId, rotation);
...
ServerCreateRagdoll expects rotation to be the world rotation and converts it to relative rotation internally. LabAPI passes data.StartRelativeRotation which is already relative, so the relative transformation is applied twice.
Additionally, the owner parameter is omitted and defaults to null.
Proposed fix:
Quaternion worldRot = WaypointBase.GetWorldRotation(data.StartRelativePosition.WaypointId, data.StartRelativeRotation);
Base = RagdollManager.ServerCreateRagdoll(data.RoleType, data.StartRelativePosition.Position, worldRot, data.Handler, data.Nickname, data.Scale, data.Serial, data.OwnerHub);