ClientSim icon indicating copy to clipboard operation
ClientSim copied to clipboard

[3.6.1] VRCPlayerApi.TeleportTo with AlignRoomWithSpawnPoint does not teleport the player to the correct location.

Open CyanLaser opened this issue 1 year ago • 1 comments

Using VRCPlayerApi.TeleportTo with AlignRoomWithSpawnPoint results in broken teleportation behavior. This has been broken since ClientSim's initial release.

Looking at the code, the handling of "from playspace" is basically the same code from CyanEmu, not properly considering how the PlayerController's hierarchy has changed.

https://github.com/vrchat-community/ClientSim/blob/43e43b046fa2aff9b31d64698fc0868df43b44eb/Packages/com.vrchat.ClientSim/Runtime/Player/ClientSimPlayerController.cs#L230-L235

https://github.com/CyanLaser/CyanEmu/blob/daf42066ab61e73c187cc6f16352304735c28343/CyanEmu/Scripts/CyanEmuPlayerController.cs#L519-L523

Here is a potential fix:

if (fromPlaySpace)
{
    var playspaceData = _trackingProvider.GetTrackingData(VRCPlayerApi.TrackingDataType.Origin);
    Vector3 playspacePos = playspaceData.position - transform.position;
    Quaternion playspaceRot = playspaceData.rotation * Quaternion.Inverse(transform.rotation);
    floorRotation = Quaternion.Inverse(playspaceRot) * floorRotation;
    position = position + floorRotation * -playspacePos;
}

I'm disappointed that no one has reported or fixed this bug in the past 3 years, even though I know many creators have referenced it...

CyanLaser avatar Jun 03 '24 21:06 CyanLaser