Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the problem with accumulating teleportation heights #1400

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,28 +216,25 @@ public void StartTeleport()
}
}

private void FinishTeleport()
{
if (currentPointingSource != null)
{
currentPointingSource = null;

if (isTeleportValid)
{
RaycastHit hitInfo;
Vector3 hitPos = teleportMarker.transform.position + Vector3.up * (Physics.Raycast(CameraCache.Main.transform.position, Vector3.down, out hitInfo, 5.0f) ? hitInfo.distance : 2.6f);

fadeControl.DoFade(0.25f, 0.5f, () =>
{
SetWorldPosition(hitPos);
}, null);
}

DisableMarker();
}
}

public void DoRotation(float rotationAmount)
private void FinishTeleport()
{
if (currentPointingSource != null)
{
currentPointingSource = null;

if (isTeleportValid)
{
fadeControl.DoFade(0.25f, 0.5f, () =>
{
SetWorldPosition(teleportMarker.transform.position);
}, null);
}

DisableMarker();
}
}

public void DoRotation(float rotationAmount)
{
if (rotationAmount != 0 && !fadeControl.Busy)
{
Expand Down Expand Up @@ -267,20 +264,22 @@ public void DoStrafe(Vector3 strafeAmount)
}
}

/// <summary>
/// Places the player in the specified position of the world
/// </summary>
/// <param name="worldPosition"></param>
public void SetWorldPosition(Vector3 worldPosition)
{
// There are two things moving the camera: the camera parent (that this script is attached to)
// and the user's head (which the MR device is attached to. :)). When setting the world position,
// we need to set it relative to the user's head in the scene so they are looking/standing where
// we expect.
transform.position = worldPosition - (CameraCache.Main.transform.position - transform.position);
}

private void EnableMarker()
/// <summary>
/// Places the player in the specified position of the world
/// </summary>
/// <param name="worldPosition"></param>
public void SetWorldPosition(Vector3 worldPosition)
{
// There are two things moving the camera: the camera parent (that this script is attached to)
// and the user's head (which the MR device is attached to. :)). When setting the world position,
// we need to set it relative to the user's head in the scene so they are looking/standing where
// we expect.
Vector3 newPosition = worldPosition - (CameraCache.Main.transform.position - transform.position);
newPosition.y = worldPosition.y;
transform.position = newPosition;
}

private void EnableMarker()
{
teleportMarker.SetActive(true);
if (animationController != null)
Expand Down