Started implementation of portal teleporting

This commit is contained in:
2025-04-02 14:47:27 +01:00
parent f76cc35c93
commit 1718bd7586
2 changed files with 6 additions and 9 deletions

View File

@@ -5,9 +5,9 @@ public partial class PlayerMovement : MonoBehaviour
private void OnTriggerStay(Collider other)
{
// Stops it trying to find the normals of portals
// if (other.CompareTag("Portal")) { return; }
if (other.CompareTag("Portal")) { return; }
// Else adds it to the list
// m_WallCollisions.Add(other);
m_WallCollisions.Add(other);
}
}

View File

@@ -57,8 +57,10 @@ public class PortalManager : MonoBehaviour
Vector3 difference = PlayerMovement.Pos() - transform.position;
float dotProduct = Vector3.Dot(transform.up, difference);
Debug.Log(dotProduct + "\t" + difference);
// If this is true the player has crossed the portal
if (dotProduct < 0f || true)
if (dotProduct < 0f)
{
Debug.Log("Teleported player");
@@ -69,16 +71,11 @@ public class PortalManager : MonoBehaviour
// Teleports the player
Vector3 offset = Quaternion.Euler(0f, rotDif, 0f) * difference;
PlayerMovement.SetPos(m_OtherManager.transform.position + offset);
PlayerMovement.SetPos(m_OtherManager.transform.position + PlayerOffset() - new Vector3(0, 2, 0));
// Stops the overlapping as it has ended
m_PlayerOverlapping = false;
}
else
{
Debug.Log("Player was not teleported");
}
}
}