Giter VIP home page Giter VIP logo

Comments (5)

maxxfrazer avatar maxxfrazer commented on September 26, 2024 1

Glad I could help! I'm going to go ahead and close this issue now.

from multipeerhelper.

maxxfrazer avatar maxxfrazer commented on September 26, 2024

Hi!

The error message you’re seeing is not directly causing issues - that message appears for me whenever I do a hitTest/raycast etc since 13.4. I think it’s an internal RealityKit message which has something to do with how they compute raycasts.

Had a quick look through, and you shouldn’t need the DidOutputCollaborationData callback, realitykit should be doing that work for you since you set the sync service here
https://github.com/chenzhutian/collaboration-interaction/blob/1813f28c101f731f4419e88fed7042148d473cb5/CollaborativeSession/ViewController.swift#L67

See the example in this repo that it isn’t called or mentioned anywhere, and the entities sync regardless.

If you add the AnchorEntity, model etc. on just one device, but still run installGestures on both once the entity has synced then that’s most of the work. The last part is transferring the ownership before actually moving the box. This could be done by catching the touchesBegan event for your ViewController, seeing if that hits your box; if it does, then request ownership and start moving it. Or by getting the response from installGestures and add a delegate to the EntityGestureRecognizers.

I’d recommend making your own gesture instead of using installGestures too, but that may be unnecessary for your purposes.

from multipeerhelper.

chenzhutian avatar chenzhutian commented on September 26, 2024

Thank you for you reply. I have removed the DidOutputCollaborationData now.
I used to think that the problem may be due to the ownership problem. But the cube even cannot be moved by the user who adds it.
Say, here is what I have:

  1. Pair A and B
  2. A adds a cube. B can see it
  3. A tries to move the cube. But the cube cannot be moved.

from multipeerhelper.

maxxfrazer avatar maxxfrazer commented on September 26, 2024

I just cloned and tried it out:

You need to remove this:
https://github.com/chenzhutian/collaboration-interaction/blob/1813f28c101f731f4419e88fed7042148d473cb5/CollaborativeSession/ViewController.swift#L110

This will tell each device to add their own cube entity, I don't think that's what you want. When the entity is moved with the EntityGestureRecognizer it moves the entity, so if each device makes their own then that won't work.

Move the code to add the Anchor + ModelEntity inside the handleTap.

After that there are a few things you could do, the simplest would probably be to have a subscriber of SceneEvents.AnchoredStateChanged running from the start and when that sees your AnchorEntity get added to the scene it installs the gestures to your ModelEntity (give it a name to check it's the one you want, just like you're currently doing on line 110). This is instead of the didAdd anchors: [ARAnchor] check.

After that you'll have to be able to transfer the ownership if you want user B to influence the movement on A.

from multipeerhelper.

chenzhutian avatar chenzhutian commented on September 26, 2024

Hi~ Thank you for your comprehensive explanation. I find out a solution:
https://github.com/chenzhutian/collaboration-interaction/blob/master/CollaborativeSession/ViewController.swift#L118

that I only add the cube for a ARAnchor that comes from the user himself.

I think it is somehow tricky, the didAdd anchors: [ARAnchor] will be invoked for all ARAnchors no matter where it comes from user A or user B. But the model attached to the anchors from user B do not need you to add again.

Next I will try to handle the ownership stuff.
Thank you again!

from multipeerhelper.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.