mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-03 06:49:22 +00:00
[DesktopVRSwitch] Testing
This commit is contained in:
parent
03514305be
commit
61a45f97bc
30 changed files with 957 additions and 524 deletions
48
DesktopVRSwitch/VRModeTrackers/MovementSystemTracker.cs
Normal file
48
DesktopVRSwitch/VRModeTrackers/MovementSystemTracker.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using ABI_RC.Systems.MovementSystem;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class MovementSystemTracker : VRModeTracker
|
||||
{
|
||||
private MovementSystem _movementSystem;
|
||||
private Vector3 preSwitchWorldPosition;
|
||||
private Quaternion preSwitchWorldRotation;
|
||||
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch += OnPreSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch -= OnPreSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPreSwitch(bool intoVR)
|
||||
{
|
||||
_movementSystem = MovementSystem.Instance;
|
||||
|
||||
Vector3 position = _movementSystem.rotationPivot.transform.position;
|
||||
position.y = _movementSystem.transform.position.y;
|
||||
preSwitchWorldPosition = position;
|
||||
preSwitchWorldRotation = _movementSystem.rotationPivot.transform.rotation;
|
||||
|
||||
_movementSystem.ChangeCrouch(false);
|
||||
_movementSystem.ChangeProne(false);
|
||||
}
|
||||
|
||||
private void OnPostSwitch(bool intoVR)
|
||||
{
|
||||
_movementSystem.rotationPivot = Utils.GetPlayerCameraObject(intoVR).transform;
|
||||
_movementSystem.TeleportToPosRot(preSwitchWorldPosition, preSwitchWorldRotation, false);
|
||||
|
||||
if (!intoVR)
|
||||
_movementSystem.UpdateColliderCenter(_movementSystem.transform.position);
|
||||
|
||||
_movementSystem.ChangeCrouch(false);
|
||||
_movementSystem.ChangeProne(false);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue