Skip to content

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

Description

@CyanLaser

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.

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

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...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions