01-08-2020 10:15 PM
Solved! Go to Solution.
06-21-2021 05:07 PM
Sorry about taking so long to get this posted. What I did to center the world is as follows
The way you add a function to the enforcer is simply done as such:
enforcer.TrackingChanged += UpdateCenter;
in this, enforcer is the GuardianBoundaryEnforce and UpdateCenter is the function that will help center the player.
UpdateCenter is as follows:
private void UpdateCenter()
boundary = OVRManager.boundary.GetDimensions(OVRBoundary.BoundaryType.PlayArea);
points = OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.PlayArea);
I personally split up the method into two just because my other method is longer and I didn't want it surrounded in the if statement of the OVRManager. That is in place to make sure we actually have a Boundary and is working correctly. If it wasn't we wouldn't be able to get any points. So now for the main show. We center the world around the guardian. To do this, I took the points from the OVRManager and put converted them to local space by putting them onto 4 points that my script creates. I them find the center between all the points and have it face forwards. from there I am able to set the rotation of the gameObject contating all the world objects to that rotation and position. Then everything is rotated.
private void CenterPlayer()
point1.transform.localPosition = (points);
point2.transform.localPosition = (points);
point3.transform.localPosition = (points);
point4.transform.localPosition = (points);
Vector3 pointA = midPoint(point1.transform.position, point2.transform.position);
Vector3 pointB = midPoint(point3.transform.position, point4.transform.position);
Vector3 between = pointB - pointA;
float distance = between.magnitude;
squareMarker.transform.position = pointA + (between / 2.0f);
worldContainer.transform.position = squareMarker.transform.position;
worldContainer.transform.rotation = squareMarker.transform.rotation;
private Vector3 midPoint(Vector3 a, Vector3 b)
float x = (a.x + b.x) / 2;
float y = (a.y + b.y) / 2;
float z = (a.z + b.z) / 2;
return new Vector3(x, y, z);
Thats all it takes to center the world around the player. If you have any other questions or have feedback on a way to improve this, please reach out!
01-09-2020 07:07 AM
01-09-2020 09:37 AM
I'm trying to accomplish the same thing with the Quest, so I'll +1 this. Out of curiosity, are you currently building to the device every time you want to test something or are you using the link cable?
01-09-2020 10:43 AM
04-10-2021 06:55 PM - edited 04-11-2021 01:37 PM
@SharpeGame Did you ever figure this out?
btw when using Oculus Link, OVRManager.boundary.GetConfigured() still returns false. To get around this, I just dumped the values returned from OVRManager.boundary.GetGeometry(OVRBoundary.BoundaryType.PlayArea) while running non-Link and use those when testing.
04-11-2021 02:04 PM
Yes, I did figure it out actually! My problem was that the code I was running was trying to align it using coordinates local to the boundary instead of the boundaries global coordinates. Once I made the conversion everything *worked* as intended. If you would like I can post a breakdown of how I accomplished this or give you some pointers on your own code if you have already attempted it.
04-21-2021 07:31 PM
Thanks for writing back! I think I understand what you are saying, but any details you wish to share would definitely be helpful for myself and future readers 🙂
06-12-2021 04:41 PM
I'm having the exact same issue. It seems that even when finding the corners, the whole play space seems to be rotated an arbitrary amount and offset from the center point. Can you please post your code sample?
06-12-2021 05:17 PM
I just found this thread which helped in my case, perhaps it will also help in your case:
06-12-2021 06:06 PM
Awesome, thank you! But this corrects it for each subsequent recentering right, and not the initial alignment? I really wish it just matched the guardian instead of these weird hacks.