Forum Discussion
neurobio.unibielefeld
1 year agoHonored Guest
CenterEyeCamera out of boundary play area not registered in Unity
Hi everybody,
I am designing a game where players actually move through space to collect targets. If they get too close to the Quest boundary I want to track that in Unity and trigger some behaviour. My code looks like this:
using unibi.homingtask.logistics;
using UnityEngine;
namespace unibi.vnt.guidance
{
public class OutOfBoundsChecker : MonoBehaviour
{
[SerializeField] private TrialDataManager trialDataManager;
[SerializeField] private PlayerManager playerManager;
[SerializeField] private Camera playerCamera;
[SerializeField] private AudioManager audioManager;
private OVRBoundary boundary;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
boundary = new OVRBoundary();
}
// Update is called once per frame
void Update()
{
checkOutOfBounds();
//if (Input.GetKeyDown(KeyCode.P))
if (OVRInput.Get(OVRInput.Button.Three))
{
Debug.Log("bounds: button triggered out of bounds");
triggerOutOfBounds();
}
}
private void checkOutOfBounds()
{
if (OVRManager.instance == null)
{
Debug.Log($"bounds: ovr manager NOT initialized");
}
else
{
Debug.Log($"bounds: ovr manager is initialized");
}
if (OVRManager.boundary != null)
{
if (OVRManager.boundary.GetConfigured())
{
Debug.Log($"bounds: configured");
}
else
{
Debug.Log($"bounds: NOT configured");
}
}
else
{
Debug.Log($"bounds: NOT initiaialized");
}
Vector3 centerEyePosition = playerCamera.transform.position;
Debug.Log($"bounds: center eye position {centerEyePosition}");
// Check if the center eye is close to the boundary
OVRBoundary.BoundaryTestResult result = boundary.TestPoint(centerEyePosition, OVRBoundary.BoundaryType.OuterBoundary);
Debug.Log($"bounds: current distance: {result.ClosestDistance} at point {result.ClosestPoint}");
if (result.IsTriggering)
{
Debug.Log("bounds: Center eye is close to the boundary!");
triggerOutOfBounds();
}
else
{
Debug.Log("bounds: Center eye safe!");
}
}
private void triggerOutOfBounds()
{
trialDataManager.TrialData.OutOfBounds = true;
playerManager.OnPlayerSteppedOutOfBounds();
audioManager.playOutOfBounds();
}
}
}
I assigned the CenterEyeCamera of my OVRCameraRig to playerCamera.
My Meta SDK All in One is updated (71.0.0), so is the OS (v72) on my Meta Quest 3. The log is telling me that "ovr manager is initialized", that it is "configured", and that the center eye position is changing the position as expected.
However, the triggerOutOfBounds() behaviour is never triggered automatically because 'result.ClosestDistance' never changes from 0.0 and 'result.ClosestPoint' is always (0.00, 0.00, 0.00).
There is only one instance of OVRManager in my scene, it is attached to an Empty GameObject.
As expected the X-Button (OVRInput.Button.Three) triggers the triggerOutOfBounds()-function as expected.
Does anybody encountered problems with registering boundary crossings in Unity or has any tips where to debug?
1 Reply
Replies have been turned off for this discussion
- neurobio.unibielefeldHonored Guest
Still wasn't able to solve the issueπ. Does anybody have any suggestions?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 months ago
- 11 months ago
- 7 months ago