mirror of
https://github.com/PashaBibko/The-Mobius-Line.git
synced 2026-04-03 17:39:03 +00:00
It "works"
It's a buggy mess but it's a working buggy mess
This commit is contained in:
@@ -48,7 +48,6 @@ MonoBehaviour:
|
|||||||
m_OtherPortal: {fileID: 0}
|
m_OtherPortal: {fileID: 0}
|
||||||
m_CameraPrefab: {fileID: 1179287573507601862, guid: 1a28b9e152b1d3d419d1881ea498fcbf, type: 3}
|
m_CameraPrefab: {fileID: 1179287573507601862, guid: 1a28b9e152b1d3d419d1881ea498fcbf, type: 3}
|
||||||
m_PortalRenderer: {fileID: 4162196787169641245}
|
m_PortalRenderer: {fileID: 4162196787169641245}
|
||||||
m_PlayerTag:
|
|
||||||
m_PlayerPoint: {fileID: 6158405577604730568}
|
m_PlayerPoint: {fileID: 6158405577604730568}
|
||||||
--- !u!65 &5568742943214540714
|
--- !u!65 &5568742943214540714
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
@@ -69,7 +68,7 @@ BoxCollider:
|
|||||||
m_ProvidesContacts: 0
|
m_ProvidesContacts: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_Size: {x: 10, y: 10, z: 0.1}
|
m_Size: {x: 10, y: 10, z: 0}
|
||||||
m_Center: {x: 0, y: 5, z: 0}
|
m_Center: {x: 0, y: 5, z: 0}
|
||||||
--- !u!1 &2957412639318883996
|
--- !u!1 &2957412639318883996
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -217,5 +216,59 @@ Transform:
|
|||||||
- {fileID: 6525768614182165007}
|
- {fileID: 6525768614182165007}
|
||||||
- {fileID: 2772991262862259612}
|
- {fileID: 2772991262862259612}
|
||||||
- {fileID: 6158405577604730568}
|
- {fileID: 6158405577604730568}
|
||||||
|
- {fileID: 8290014685027761188}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &7967144210440699741
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 8290014685027761188}
|
||||||
|
- component: {fileID: 4196137517685965440}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Back
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &8290014685027761188
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7967144210440699741}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 3117384245817137028}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!65 &4196137517685965440
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7967144210440699741}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_ProvidesContacts: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Size: {x: 10, y: 10, z: 5}
|
||||||
|
m_Center: {x: 0, y: 5, z: -3.5}
|
||||||
|
|||||||
@@ -70,4 +70,7 @@ public class CameraController : MonoBehaviour
|
|||||||
// Sets its location to where it is tracking
|
// Sets its location to where it is tracking
|
||||||
transform.position = m_Tracking.position;
|
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
|
// Fixed Update is called once per physics update
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
// Resets portal state
|
||||||
|
m_PortalFrameCounter = Mathf.Max(0, m_PortalFrameCounter - 1);
|
||||||
|
|
||||||
// Works out the new state of the player
|
// Works out the new state of the player
|
||||||
UpdatePlayerState();
|
UpdatePlayerState();
|
||||||
|
|
||||||
@@ -81,10 +84,21 @@ public partial class PlayerMovement : MonoBehaviour
|
|||||||
m_Body.velocity = v;
|
m_Body.velocity = v;
|
||||||
|
|
||||||
// Doubles gravity if falling to feel less floaty
|
// Doubles gravity if falling to feel less floaty
|
||||||
if (v.y < 0.0f) { GravityController.Instance().SetScale(8.0f); }
|
if (v.y < 0.0f) { GravityController.Instance().SetScale(2f); }
|
||||||
else { GravityController.Instance().SetScale(3f); }
|
else { GravityController.Instance().SetScale(1f); }
|
||||||
|
|
||||||
// Clears all stored collisions
|
// Clears all stored collisions
|
||||||
m_WallCollisions.Clear();
|
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;
|
Vector3 m_WallNormal;
|
||||||
|
|
||||||
|
//
|
||||||
|
int m_PortalFrameCounter = 0;
|
||||||
|
|
||||||
// Only instance of the player
|
// Only instance of the player
|
||||||
static PlayerMovement s_Instance;
|
static PlayerMovement s_Instance;
|
||||||
|
|
||||||
@@ -89,6 +92,8 @@ public partial class PlayerMovement : MonoBehaviour
|
|||||||
public static Vector3 Pos() => s_Instance.transform.position;
|
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) => s_Instance.transform.parent.position = v;
|
||||||
public static GameObject Object() => s_Instance.gameObject;
|
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
|
// Start is called before the first frame update
|
||||||
private void Start()
|
private void Start()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
public partial class PlayerMovement : MonoBehaviour
|
public partial class PlayerMovement : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -56,6 +57,12 @@ public partial class PlayerMovement : MonoBehaviour
|
|||||||
ApplyDrag();
|
ApplyDrag();
|
||||||
|
|
||||||
// Displays the speed of the player to the screen
|
// 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);
|
m_Body.AddForce(slopeDir.normalized * m_SlideSpeed * m_Body.mass * 10, ForceMode.Force);
|
||||||
|
|
||||||
// Checks if the player wants to jump
|
// 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
|
// 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
|
else
|
||||||
{
|
{
|
||||||
Debug.LogError("SOMETHING WENT WRONG");
|
|
||||||
normal = Vector3.zero;
|
normal = Vector3.zero;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using UnityEditor.UIElements;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PortalManager : MonoBehaviour
|
public class PortalManager : MonoBehaviour
|
||||||
@@ -54,25 +53,25 @@ public class PortalManager : MonoBehaviour
|
|||||||
// Checks if the player is overlapping with the portal
|
// Checks if the player is overlapping with the portal
|
||||||
if (m_PlayerOverlapping)
|
if (m_PlayerOverlapping)
|
||||||
{
|
{
|
||||||
|
// Calculates if the player is going towards the portal
|
||||||
Vector3 difference = PlayerMovement.Pos() - transform.position;
|
Vector3 difference = PlayerMovement.Pos() - transform.position;
|
||||||
float dotProduct = Vector3.Dot(transform.up, difference);
|
float dotProduct = Vector3.Dot(m_PortalRenderer.gameObject.transform.up, difference);
|
||||||
|
|
||||||
Debug.Log(dotProduct + "\t" + difference);
|
|
||||||
|
|
||||||
// If this is true the player has crossed the portal
|
// If this is true the player has crossed the portal
|
||||||
if (dotProduct < 0f)
|
if (dotProduct < 0f && PlayerMovement.CanGoThroughPortals())
|
||||||
{
|
{
|
||||||
Debug.Log("Teleported player");
|
|
||||||
|
|
||||||
// Rotates the player
|
// Rotates the player
|
||||||
float rotDif = -Quaternion.Angle(transform.rotation, m_OtherManager.transform.rotation);
|
float rotDif = -Quaternion.Angle(transform.rotation, m_OtherManager.transform.rotation);
|
||||||
rotDif += 180.0f;
|
rotDif += 180.0f;
|
||||||
PlayerMovement.Orientation().Rotate(Vector3.up, rotDif);
|
CameraController.Instance().RotatePlayerDirection(new Vector2(0f, rotDif));
|
||||||
|
|
||||||
// Teleports the player
|
// Teleports the player
|
||||||
Vector3 offset = Quaternion.Euler(0f, rotDif, 0f) * difference;
|
Vector3 offset = Quaternion.Euler(0f, rotDif, 0f) * difference;
|
||||||
PlayerMovement.SetPos(m_OtherManager.transform.position + PlayerOffset() - new Vector3(0, 2, 0));
|
PlayerMovement.SetPos(m_OtherManager.transform.position + PlayerOffset() - new Vector3(0, 2, 0));
|
||||||
|
|
||||||
|
// Tellss the player it went through a portal
|
||||||
|
PlayerMovement.Instance().WentThroughPortal(rotDif);
|
||||||
|
|
||||||
// Stops the overlapping as it has ended
|
// Stops the overlapping as it has ended
|
||||||
m_PlayerOverlapping = false;
|
m_PlayerOverlapping = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user