Epilepsy sim

This commit is contained in:
2025-04-02 13:45:27 +01:00
parent 01242dd807
commit f76cc35c93
9 changed files with 2059 additions and 679 deletions

View File

@@ -10,9 +10,10 @@ GameObject:
m_Component:
- component: {fileID: 6525768614182165007}
- component: {fileID: 4470023418895194988}
m_Layer: 0
- component: {fileID: 5568742943214540714}
m_Layer: 12
m_Name: Manager
m_TagString: Untagged
m_TagString: Portal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -47,41 +48,29 @@ MonoBehaviour:
m_OtherPortal: {fileID: 0}
m_CameraPrefab: {fileID: 1179287573507601862, guid: 1a28b9e152b1d3d419d1881ea498fcbf, type: 3}
m_PortalRenderer: {fileID: 4162196787169641245}
m_PlayerTag:
m_PlayerPoint: {fileID: 6158405577604730568}
m_Pos: {fileID: 8037706452414992202}
m_Rot: {fileID: 7913558143758367436}
--- !u!1 &1109503274534853756
GameObject:
--- !u!65 &5568742943214540714
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7913558143758367436}
m_Layer: 0
m_Name: Rot
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7913558143758367436
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1109503274534853756}
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:
- {fileID: 8037706452414992202}
m_Father: {fileID: 3117384245817137028}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_GameObject: {fileID: 854078383130308031}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 10, y: 10, z: 0.1}
m_Center: {x: 0, y: 5, z: 0}
--- !u!1 &2957412639318883996
GameObject:
m_ObjectHideFlags: 0
@@ -91,9 +80,9 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 6158405577604730568}
m_Layer: 0
m_Layer: 12
m_Name: PlayerPos
m_TagString: Untagged
m_TagString: Portal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -124,9 +113,9 @@ GameObject:
- component: {fileID: 2772991262862259612}
- component: {fileID: 5956259521933674024}
- component: {fileID: 4162196787169641245}
m_Layer: 0
m_Layer: 12
m_Name: RenderSurface
m_TagString: Untagged
m_TagString: Portal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -196,37 +185,6 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &4970227605924577730
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8037706452414992202}
m_Layer: 0
m_Name: Pos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8037706452414992202
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4970227605924577730}
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: 7913558143758367436}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5834152528747782185
GameObject:
m_ObjectHideFlags: 0
@@ -236,9 +194,9 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 3117384245817137028}
m_Layer: 0
m_Layer: 12
m_Name: Portal
m_TagString: Untagged
m_TagString: Portal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -258,7 +216,6 @@ Transform:
m_Children:
- {fileID: 6525768614182165007}
- {fileID: 2772991262862259612}
- {fileID: 7913558143758367436}
- {fileID: 6158405577604730568}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@@ -13,7 +13,7 @@ GameObject:
- component: {fileID: 1896638422029351328}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_TagString: Portal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -94,7 +94,7 @@ GameObject:
- component: {fileID: 8674285141076725919}
m_Layer: 0
m_Name: PortalCam
m_TagString: Untagged
m_TagString: Portal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -129,7 +129,7 @@ GameObject:
- component: {fileID: 1977297312153635828}
m_Layer: 0
m_Name: Camera
m_TagString: Untagged
m_TagString: Portal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -82,9 +82,27 @@ public partial class PlayerMovement : MonoBehaviour
//
Vector3 m_WallNormal;
// 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 GameObject Object() => s_Instance.gameObject;
// Start is called before the first frame update
private void Start()
{
// Checks there is not more than one player at one time
if (s_Instance != null)
{
Debug.LogError("Multiple players");
return;
}
// Sets it to the instance
s_Instance = this;
// Stops the rigidbody from rotatating when we don't want it to
m_Body.freezeRotation = true;

View File

@@ -31,8 +31,7 @@ public partial class PlayerMovement : MonoBehaviour
Vector3 point = closest.ClosestPoint(transform.position);
Vector3 dir = point - transform.position;
RaycastHit hit;
if (Physics.Raycast(transform.position, dir.normalized, out hit, (m_WallCheckDistance * 2.0f) + 1.0f, m_GroundMask))
if (Physics.Raycast(transform.position, dir.normalized, out RaycastHit hit, (m_WallCheckDistance * 2.0f) + 1.0f, m_GroundMask))
{
normal = hit.normal;
return true;

View File

@@ -21,12 +21,10 @@ public class PortalCamera : MonoBehaviour
// Initialistion function for the camera
public void InitCamera(MeshRenderer renderer, PortalManager creator, Vector3 rot)
{
Debug.Log(rot);
//
// Transfers the passed rotation to be stored within the class
m_Rot = rot;
//
// Stores both portals
m_CapturePortal = creator.Linked();
m_DisplayPortal = creator;

View File

@@ -1,3 +1,4 @@
using UnityEditor.UIElements;
using UnityEngine;
public class PortalManager : MonoBehaviour
@@ -12,10 +13,17 @@ public class PortalManager : MonoBehaviour
[Header("Points")]
[SerializeField] Transform m_PlayerPoint;
// Private variables //
PortalManager m_OtherManager;
PortalCamera m_PortalCamera;
bool m_PlayerOverlapping = false;
// Gets the other end of the portal
public PortalManager Linked() => m_OtherManager;
// Gets the location of the player relative to the portal
public Vector3 PlayerOffset() => m_PlayerPoint.localPosition;
// Start is called before the first frame update
@@ -40,6 +48,54 @@ public class PortalManager : MonoBehaviour
// Updates is called every frame
void Update()
{
// Updates the player position relative to the portal
m_PlayerPoint.position = CameraController.Instance().transform.position;
// Checks if the player is overlapping with the portal
if (m_PlayerOverlapping)
{
Vector3 difference = PlayerMovement.Pos() - transform.position;
float dotProduct = Vector3.Dot(transform.up, difference);
// If this is true the player has crossed the portal
if (dotProduct < 0f || true)
{
Debug.Log("Teleported player");
// Rotates the player
float rotDif = -Quaternion.Angle(transform.rotation, m_OtherManager.transform.rotation);
rotDif += 180.0f;
PlayerMovement.Orientation().Rotate(Vector3.up, rotDif);
// Teleports the player
Vector3 offset = Quaternion.Euler(0f, rotDif, 0f) * difference;
PlayerMovement.SetPos(m_OtherManager.transform.position + offset);
// Stops the overlapping as it has ended
m_PlayerOverlapping = false;
}
else
{
Debug.Log("Player was not teleported");
}
}
}
// When something enters the portal
private void OnTriggerEnter(Collider other)
{
// Changing the state if it is not the player will causes issues
if (other.CompareTag(PlayerMovement.Object().tag) == false) { return; }
m_PlayerOverlapping = true;
}
// When something exits the portal
private void OnTriggerExit(Collider other)
{
// Changing the state if it is not the player will causes issues
if (other.CompareTag(PlayerMovement.Object().tag) == false) { return; }
m_PlayerOverlapping = false;
}
}

View File

@@ -3,7 +3,9 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- Portal
- NoTag
layers:
- Default
- TransparentFX
@@ -17,7 +19,7 @@ TagManager:
- Player
- Ground
- Slope
-
- Portal
-
-
-