LabAPI icon indicating copy to clipboard operation
LabAPI copied to clipboard

[BUG]: Ragdoll.UnFreeze() applies relative rotation twice and wipes OwnerHub reference

Open efrosim opened this issue 3 weeks ago • 0 comments

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

  1. Spawn or locate a player ragdoll.
  2. Call ragdoll.Freeze().
  3. Call ragdoll.UnFreeze().
  4. Observe that the ragdoll orientation is twisted incorrectly and ragdoll.Owner is 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);

efrosim avatar Nov 11 '26 18:11 efrosim