Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Added roomscale movement
Browse files Browse the repository at this point in the history
  • Loading branch information
LivingFray committed Jan 9, 2023
1 parent 24d7f31 commit 9d470fc
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions HellsingerVR/Components/VRRig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class VRRig : MonoBehaviour

public VRViewModelManager viewModelManager;

private FirstPersonController fpController;

private Vector3 RoomscaleOffset = Vector3.zero;

public bool InLevel
Expand Down Expand Up @@ -81,7 +83,7 @@ public void EnterCutscene()

InCutscene = true;

FirstPersonController fpController = FindObjectOfType<FirstPersonController>();
fpController = FindObjectOfType<FirstPersonController>();
if (fpController)
{
PlayerTransform = fpController.m_player.PlayerTransform;
Expand All @@ -98,11 +100,10 @@ public void ExitCutscene()

LastLocalHeadYaw = head.localRotation.eulerAngles.y;

//RoomscaleOffset = -head.localPosition;
//RoomscaleOffset.y = 0;
RoomscaleOffset = head.localPosition;
RoomscaleOffset.y = 0;

//transform.position = PlayerTransform.position + RoomscaleOffset;
transform.position = PlayerTransform.position;
transform.position = PlayerTransform.position - RoomscaleOffset;
transform.rotation = PlayerTransform.rotation * Quaternion.Euler(0.0f, -head.localRotation.eulerAngles.y, 0.0f);

if (rhythmIndicator == null)
Expand Down Expand Up @@ -197,14 +198,25 @@ public void UpdateTransform()

CameraTransform.rotation = Quaternion.Euler(head.rotation.eulerAngles.x, NewYaw, 0.0f);

//Vector3 RoomscaleMovement = head.localPosition - RoomscaleOffset;
//RoomscaleMovement.y = 0;

bool IsDoingAnimatedMove = fpController.GetCurrentMovementStateType() == MovementStateType.Overkill;

if (!IsDoingAnimatedMove)
{
Vector3 RoomscaleMovement = head.localPosition - RoomscaleOffset;
RoomscaleMovement.y = 0;

//FindObjectOfType<FirstPersonController>().m_player.CharacterController.Move(RoomscaleMovement / Time.deltaTime);
fpController.m_player.CharacterController.Move(RoomscaleMovement);

//RoomscaleOffset = -head.localPosition;
RoomscaleOffset = head.localPosition;
RoomscaleOffset.y = 0;

transform.position = PlayerTransform.position + RoomscaleOffset;
transform.position = PlayerTransform.position - RoomscaleOffset;
}
else
{
transform.position = PlayerTransform.position;
}
transform.rotation = Quaternion.Euler(0.0f, NewYaw - LastLocalHeadYaw, 0.0f);
}
}
Expand Down

0 comments on commit 9d470fc

Please sign in to comment.