Different coordinate systems

I'm trying to use network transforms to synchronize moving objects. But a network transform sends position/movement information relative to the current device's coordinate system (in which the origin is located at the position of the HoloLens I think?). Another HoloLens has a different coordinate system and so the synchronization doesn't work.

It sounds like Spatial Anchors are what I should be using, but I can't figure out how Network Transforms and Spatial Anchors can work together.

Tagged:

Answers

  • stepan_stulovstepan_stulov ✭✭✭
    edited April 2018

    Hey, @myieye

    I'm not completely familiar with NetworkTransform, but a quick googling revealed this:

    https://docs.unity3d.com/Manual/class-NetworkTransformChild.html

    You need to make sure you don't have NetworkTransform and world anchors conflicting, since these are two different systems working on the same component (Transform). Have a look at these threads:

    https://forums.hololens.com/discussion/comment/20825
    https://forums.hololens.com/discussion/comment/15033

    Cheers

    Building the future of holographic navigation. We're hiring.

  • dbarrettdbarrett ✭✭✭

    This is a very common problem some people have when working with multiplayer. There are a bunch of different ways for moving objects, some of which do not require Network Transforms. However, if you want to proceed this way, all you need to do is take your sharedAnchorTransform and set the position of your object to the InverseTransformPoint of that sharedAnchorTransform. It should look something like this:

    [SyncVar] Vector3 localPosition;

    localPosition = sharedAnchorTransform.InverseTransformPoint(objPosition);

    then right after you would update the position on the server with a method like below:

    [Command]
    CmdTransform(Vector3 position) { if(!isLocalPlayer) localPosition = position; }

    You would only set localPosition if you have Authority over that object, otherwise you would just get that variable.

    AR Developer

Sign In or Register to comment.