0
\$\begingroup\$

I am out of options. I have tried everything I could and no matter what I do, the Transforms don't sync up. I have had multiple solutions that worked in my test, non AR project, but once I put on the HoloLens, it doesn't work. Here is what I did:

//PlayerObject that is spawned by the NetworkManager
//(obviously has Network Identity component)
public class ClientObject : NetworkBehaviour {
    public static ClientObject CurrentClient;

    private void Start() {
        if(isLocalClient) CurrentClient = this;
    }

    public void MoveObject(GameObject obj, Vector3 position) {
        Cmd_MoveObject(obj, position);
    }

    [Command]
    public void Cmd_MoveObject(GameObject obj, Vector3 position) {
        obj.transform.localPosition = position;
    }
}

And now the object that wants to get synced. It has a Network Transform with standard settings, a network identity and (obviously) no-one has authority since it doesn't get spawned:

public class AnObject : MonoBehaviour {
    public void IWasMoved() {
        /*
         * Someone Moved this object, either by dragging it or
         * clicking on one of it's arrows through the hololons.
         */

        Vector3 newPosition = (the new position i want this object to have);
        ClientObject.CurrentClient.MoveObject(gameObject, newPosition);
    }
}

That's what I have. The only thing different from the version that works on my PC without the HoloLens is that I don't set localPosition = position, but instead use Translate(position) (which is obviously the non local version);

I am tired of writing new code, building the project, having Visual Studio translate the code to C++, start my HoloLenses and test if it works, which takes over an hour every time I do so.

So: is there anything fundamentally wrong with my code? Again: it works on my test project just fine. I refuse to believe that it's the HoloLens's fault...

\$\endgroup\$
0
\$\begingroup\$

So as far as i'm aware this has no solution. Apparently the hololens is incompatable with syncing objects that weren't spawned in Unet. I took the long road and coded the entire backend of server and client communication since Unet is unable to handle it... A pity.

New contributor
Yiasmat is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.