mirror of
https://github.com/PashaBibko/The-Mobius-Line.git
synced 2026-04-04 01:49:07 +00:00
It "works"
It's a buggy mess but it's a working buggy mess
This commit is contained in:
@@ -70,4 +70,7 @@ public class CameraController : MonoBehaviour
|
||||
// Sets its location to where it is tracking
|
||||
transform.position = m_Tracking.position;
|
||||
}
|
||||
|
||||
// Adds a way for external forces to modify the direction the player is looking
|
||||
public void RotatePlayerDirection(Vector2 dif) => m_Rotation += dif;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
// Fixed Update is called once per physics update
|
||||
private void FixedUpdate()
|
||||
{
|
||||
// Resets portal state
|
||||
m_PortalFrameCounter = Mathf.Max(0, m_PortalFrameCounter - 1);
|
||||
|
||||
// Works out the new state of the player
|
||||
UpdatePlayerState();
|
||||
|
||||
@@ -81,10 +84,21 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
m_Body.velocity = v;
|
||||
|
||||
// Doubles gravity if falling to feel less floaty
|
||||
if (v.y < 0.0f) { GravityController.Instance().SetScale(8.0f); }
|
||||
else { GravityController.Instance().SetScale(3f); }
|
||||
if (v.y < 0.0f) { GravityController.Instance().SetScale(2f); }
|
||||
else { GravityController.Instance().SetScale(1f); }
|
||||
|
||||
// Clears all stored collisions
|
||||
m_WallCollisions.Clear();
|
||||
}
|
||||
|
||||
public void WentThroughPortal(float change)
|
||||
{
|
||||
// Resets the counter
|
||||
m_PortalFrameCounter = 3;
|
||||
|
||||
// Rotates the velocity of the player
|
||||
Vector3 vel = m_Body.velocity;
|
||||
vel = Quaternion.AngleAxis(change, Vector3.up) * vel;
|
||||
m_Body.velocity = vel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,9 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
//
|
||||
Vector3 m_WallNormal;
|
||||
|
||||
//
|
||||
int m_PortalFrameCounter = 0;
|
||||
|
||||
// Only instance of the player
|
||||
static PlayerMovement s_Instance;
|
||||
|
||||
@@ -89,6 +92,8 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
public static Vector3 Pos() => s_Instance.transform.position;
|
||||
public static void SetPos(Vector3 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;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public partial class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
@@ -56,6 +57,12 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
ApplyDrag();
|
||||
|
||||
// Displays the speed of the player to the screen
|
||||
m_SpeedDisplay.text = "Speed: " + new Vector3(m_Body.velocity.x, 0.0f, m_Body.velocity.z).magnitude.ToString("0.00") + " m/s";
|
||||
m_SpeedDisplay.text = new Vector3(m_Body.velocity.x, 0.0f, m_Body.velocity.z).magnitude.ToString("0.00") + " m/s";
|
||||
|
||||
// Reloads the game to stop falling off
|
||||
if (Input.GetKey(KeyCode.R))
|
||||
{
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
m_Body.AddForce(slopeDir.normalized * m_SlideSpeed * m_Body.mass * 10, ForceMode.Force);
|
||||
|
||||
// Checks if the player wants to jump
|
||||
if (m_JumpKeyPressed) { Jump(5.0f, true); }
|
||||
if (m_JumpKeyPressed) { Jump(2.0f, true); }
|
||||
}
|
||||
|
||||
// If at the start of a slide provides a boost to the player or if the player is on a slope
|
||||
|
||||
@@ -39,7 +39,6 @@ public partial class PlayerMovement : MonoBehaviour
|
||||
|
||||
else
|
||||
{
|
||||
Debug.LogError("SOMETHING WENT WRONG");
|
||||
normal = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user