I wanna go to bed

This commit is contained in:
2025-04-04 11:46:10 +01:00
parent 653876e56e
commit 46db31b405
5 changed files with 522 additions and 496 deletions

View File

@@ -25,6 +25,13 @@ public partial class PlayerMovement : MonoBehaviour
// Resets portal state
m_PortalFrameCounter = Mathf.Max(0, m_PortalFrameCounter - 1);
// Transfers all stored velocity to the player
if (m_StoredVel != Vector3.zero)
{
m_Body.velocity = m_StoredVel;
m_StoredVel = Vector3.zero;
}
// Works out the new state of the player
UpdatePlayerState();
@@ -94,11 +101,14 @@ public partial class PlayerMovement : MonoBehaviour
public void WentThroughPortal(float change)
{
// Resets the counter
m_PortalFrameCounter = 3;
m_PortalFrameCounter = 5;
// Rotates the velocity of the player
Vector3 vel = m_Body.velocity;
vel = Quaternion.AngleAxis(change, Vector3.up) * vel;
m_Body.velocity = vel;
// Stores the velocity
m_StoredVel = vel;
}
}

View File

@@ -85,12 +85,20 @@ public partial class PlayerMovement : MonoBehaviour
//
int m_PortalFrameCounter = 0;
//
Vector3 m_StoredVel;
// Only instance of the player
static PlayerMovement s_Instance;
public static Transform Orientation() => s_Instance.m_Orientation;
public static Vector3 Pos() => s_Instance.transform.position;
public static void SetPos(Vector3 v) => s_Instance.transform.parent.position = v;
public static void SetPos(Vector3 v)
{
//Debug.Log(v);
s_Instance.transform.parent.position = v;
}
public static GameObject Object() => s_Instance.gameObject;
public static bool CanGoThroughPortals() => s_Instance.m_PortalFrameCounter == 0;
public static PlayerMovement Instance() => s_Instance;