Skip to content

Commit 3081df0

Browse files
committed
preserve mouse y rotation on teleport
1 parent cf024d7 commit 3081df0

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using UnityEngine;
88
using Harmony;
99

10-
[assembly: MelonInfo(typeof(SuperliminalPracticeMod.Main), "Superliminal Practice Mod", "0.4.0", "Micrologist#2351")]
10+
[assembly: MelonInfo(typeof(SuperliminalPracticeMod.Main), "Superliminal Practice Mod", "0.4.1", "Micrologist#2351")]
1111
[assembly: MelonGame("PillowCastle", "Superliminal")]
1212
[assembly: MelonGame("PillowCastle", "SuperliminalSteam")]
1313
[assembly: MelonGame("PillowCastle", "SuperliminalGOG")]

PracticeModManager.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ class PracticeModManager : MonoBehaviour
1919
public Text playerText;
2020
public Text grabbedObjectText;
2121
public PauseMenu pauseMenu;
22+
public MouseLook mouseLook;
2223

2324
Vector3 storedPosition;
24-
Quaternion storedRotation;
25+
Quaternion storedCapsuleRotation;
26+
float storedCameraRotation;
2527
float storedScale;
2628
int storedMap;
2729
float storeTime;
@@ -41,7 +43,8 @@ void Awake()
4143
defaultFarClipPlane = 999f;
4244

4345
storedPosition = Vector3.zero;
44-
storedRotation = Quaternion.identity;
46+
storedCapsuleRotation = Quaternion.identity;
47+
storedCameraRotation = 0;
4548
storedScale = 1.0f;
4649
storedMap = -1;
4750
GameManager.GM.enableDebugFunctions = true;
@@ -97,6 +100,7 @@ void Update()
97100
player = GameManager.GM.player;
98101
playerMotor = player.GetComponent<CharacterMotor>();
99102
playerCamera = player.GetComponentInChildren<Camera>();
103+
mouseLook = playerCamera.GetComponent<MouseLook>();
100104
resizeScript = playerCamera.GetComponent<ResizeScript>();
101105
pauseMenu = GameObject.Find("UI_PAUSE_MENU").GetComponentInChildren<PauseMenu>(true);
102106
defaultFarClipPlane = playerCamera.farClipPlane;
@@ -386,7 +390,8 @@ string GetGrabbedObjectTextString()
386390
void StorePosition()
387391
{
388392
storedPosition = playerMotor.transform.position;
389-
storedRotation = playerMotor.transform.rotation;
393+
storedCapsuleRotation = playerMotor.transform.rotation;
394+
storedCameraRotation = mouseLook.rotationY;
390395
storedScale = playerMotor.transform.localScale.x;
391396
storedMap = SceneManager.GetActiveScene().buildIndex;
392397
storeTime = Time.time;
@@ -397,7 +402,8 @@ void TeleportPosition()
397402
if(storedMap == SceneManager.GetActiveScene().buildIndex)
398403
{
399404
playerMotor.transform.position = storedPosition;
400-
playerMotor.transform.rotation = storedRotation;
405+
playerMotor.transform.rotation = storedCapsuleRotation;
406+
mouseLook.SetRotationY(storedCameraRotation);
401407
Scale(storedScale);
402408
teleportTime = Time.time;
403409
}

0 commit comments

Comments
 (0)