Skip to content

Commit

Permalink
Fix out of bounds camera in the player's room map
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Aug 4, 2023
1 parent c8aea63 commit 04254f1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion MainGameVR/Camera/VRCameraMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ public void MoveTo(Vector3 position, Quaternion rotation, bool keepHeight, bool
}
if (!quiet)
{
#if DEBUG
VRLog.Debug("Moving camera to pos={0} rot={1} Trace:\n{2}", position, rotation.eulerAngles, new StackTrace(1));
#else
VRLog.Debug("Moving camera to pos={0} rot={1}", position, rotation.eulerAngles);
#endif
}


_lastPosition = position;
_lastRotation = rotation;

Expand Down Expand Up @@ -84,6 +89,8 @@ public void MaybeMoveADV(ADV.TextScenario textScenario, Vector3 position, Quater

var closerPosition = AdjustAdvPosition(textScenario, position, rotation);

AdjustBasedOnMap(ref closerPosition, ref rotation);

MoveWithHeuristics(closerPosition, rotation, keepHeight, !advFade.IsEnd);
}

Expand Down Expand Up @@ -167,11 +174,30 @@ public void HandleTextScenarioProgress(ADV.TextScenario textScenario)
{
var target = ActionCameraControl.GetIdealTransformFor(textScenario.AdvCamera);
var targetPosition = target.position;
var targetRotation = target.rotation;

targetPosition = AdjustAdvPosition(textScenario, targetPosition, target.rotation);

AdjustBasedOnMap(ref targetPosition, ref targetRotation);

if (ActionCameraControl.HeadIsAwayFromPosition(targetPosition))
MoveWithHeuristics(targetPosition, target.rotation, false, isFadingOut);
MoveWithHeuristics(targetPosition, targetRotation, false, isFadingOut);
}
}

private static void AdjustBasedOnMap(ref Vector3 targetPosition, ref Quaternion targetRotation)
{
var insideMyRoom = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "GasyukuMyroom";
if (insideMyRoom)
{
var middleOfRoom = new Vector3(1.3f, 1.6f, 1.2f);

if (Vector3.Distance(targetPosition, middleOfRoom) > 10)
{
targetPosition = middleOfRoom;
var middleOfRoomRotation = Quaternion.Euler(0, 180, 0);
targetRotation = middleOfRoomRotation;
}
}
}

Expand Down

0 comments on commit 04254f1

Please sign in to comment.