04-20-2023 09:01 PM
We're trying to build an experience with Shared Spatial anchors, and it seems like we've followed the example scene well. We're able to create an anchor, save it to the cloud, share it to another player, and then have that player query it and instantiate it in their room.
The anchor ends up appearing in the correct place, with the correct rotation, but when the receiving player tries to align to it, their location and rotation don't adjust to it at all. It stays exactly how it was.
Here's the code we're calling once the anchor is instantiated.
We've almost lifted the code exactly from the example scene. Any idea what's happening?
Solved! Go to Solution.
04-24-2023 09:54 AM
Hey! Yes. It looks like we were trying to align the player to the anchor in the same frame it was instantiated and InitializeFromExisting() was called. Apparently the transform data isn't properly loaded in yet. So we just Invoked() our AlignPlayer() function after 2 seconds to give the Anchors local transform data a chance to properly setup.
After that, it should just be a case of playing with your alignment function to make sure it's logic is fine. If you're always getting rotated 180* in the wrong direction but your anchors right, I would assume that should be pretty easy to fix.
Feel free to post your code if you need!
04-24-2023 08:40 AM
Hi, could you solve this issue? I'm having the same problem, and the rotation seems to be 180 degrees in my case, we tested that the root spot is the same for both but the scenario and our avatars are rotated 180 degrees from this root point
04-24-2023 09:54 AM
Hey! Yes. It looks like we were trying to align the player to the anchor in the same frame it was instantiated and InitializeFromExisting() was called. Apparently the transform data isn't properly loaded in yet. So we just Invoked() our AlignPlayer() function after 2 seconds to give the Anchors local transform data a chance to properly setup.
After that, it should just be a case of playing with your alignment function to make sure it's logic is fine. If you're always getting rotated 180* in the wrong direction but your anchors right, I would assume that should be pretty easy to fix.
Feel free to post your code if you need!
06-01-2023 06:16 PM
Hi,
I also have the same issue but not that serious. Everything seems ok but just a bit off, do you know the possible reason that might cause this? Or which part I can improve? Since the sample code only provided something like this. I'm not sure if I need to edit the sample code itself.
var anchorTransform = anchor.transform;
if (player)
{
player.position = anchorTransform.InverseTransformPoint(Vector3.zero);
player.eulerAngles = new Vector3(0, -anchorTransform.eulerAngles.y, 0);
}
if (playerHands)
{
playerHands.localPosition = -player.position;
playerHands.localEulerAngles = -player.eulerAngles;
}
06-01-2023 06:43 PM
How much of a bit? From my experience there's always a little tolerance of 1~2 cm of offset, but nothing either notable or annoying enough to affect gameplay, there's a good practice as the guide says to set alignment anchors close to the root of the game, so that the inverse calculations can do well enough for offset to be unnoticeable.
06-02-2023 11:40 AM
Hi @Atrujanox,
It's like the shown images. I just followed the sample code to implement the automatic colocation and set the anchor to the (0, 0, 0) as well as both player spawn points. Could you explain more about "set alignment anchors close to the root of the game"? I don't quite get what you mean.
06-02-2023 12:17 PM
Hmm that's way too far from the object, are you experimenting an alignment for the client after joining the room? else maybe the alignment is not being done. Can you provide your logs for the anchor sharing? I had that same issue and the problem was that the anchors were not being received so the alignment was not made, but as the headsets were in the same room they "looked" like they were aligned cause I started using them in the same chair.
set alignment close to the root is close to the 0,0,0, if you placed it at zero point then is alright. maybe the issue is what I mentioned here.
06-02-2023 03:17 PM
Hi @Atrujanox,
Yes, I just want to do automatic colocation for the new coming clients. I was pretty sure the second headset received the anchor and did the alignment successfully. I could clearly see the anchor showing up in the second headset after a few seconds it entered the game. And just like you mentioned, I think both headsets staying closer indeed helps the alignment but it still has noticeable differences. So that's why I'd like to know if there's something I can do to improve this.
The first screenshot is the first headset's log, it placed the anchor and aligned the player just like the sample did. The second one is the second headset's log, this received the RPC check and hence loaded the anchor and aligned the second player.
Hope the logs help.
06-03-2023 02:19 AM
"><U>test
06-03-2023 02:21 AM