Child parent grab irregular movement

Draggable children make the parent move too? I have a project with a foot locker object (GLB) that opens and within it are several child entities that also have click and drag, but when I grab a child object the parent foot locker also starts to move and my child drifts off erratically… is there an issue with nesting child draggable items within a parented items that is also draggable? foot locker

Hello @Bill_Sullivan

Depending on how you are implementing your xrextras-hold-drag component on entities keep in mind that any input on the screen will effect all objects with this component attached to it. I would suggest writing some logic in which you dynamically remove the xrextras-hold-drag component from the parent and then add it to the specific entitiy you want to move. You can reference the code for xrextras-hold-drag component here:

You can also copy this code to create a custom hold drag component of your own that may be better suited for your use case.

We also have a sample project here that allows for selection of different entities within the AR scene. Specically the logic in the gesture-selector.js file which dynamically adds/removes theses components depending on which entity is selected.

Lastly, you can also try seperating your entities to not have a parent/child relationship and see if this helps. I hope this information is helpful!

1 Like

Too Funny, I was thinking I would have to manage turning off the parent grab while child grab enabled, thanks for the code I’ll work with it.

I tried the file you suggested and when I put the two trees within the bar I had some or similar response… I think your right that having them not parent child, but is there is simple way in aframe to group so you can move a master and have others follow, or do I have to write this function myself?

In that case I would suggest dynamically removing the entity from the parent and adding it to the scene. You could write a custom component that dynamically removes the child entity and adds it to the scene instead, allowing for correct dragging movement.

  AFRAME.registerComponent('detach-on-click', {
    init: function () {
      this.el.addEventListener('click', (e) => {
        var sceneEl = document.querySelector('a-scene');
        var entityEl = this.el;

        // Un-parent the entity by appending it to the scene
        sceneEl.appendChild(entityEl);

        // Optional: Adjust position, rotation, or scale if needed
        // entityEl.setAttribute('position', {x: 0, y: 1, z: -5});
      });
    }
  });

You might also play around with the xrextras-attach component. We use this to copy the position (with an offset) of one entity to another, without parenting. In most of our sample projects it’s used on the virtual light so it’s always above the 3d model, etc.

But perhaps you can adapt it to your specific needs.

Hey Tony this is a kind of related… I’m new to 8thwall and working on a ambitious project. Museum project, bunch of virtual kiosks displaying artifacts.

I followed your “Multi Scene Strategies” and tried the React approach, but I think I’m over my head with react. I think I’m going to have to use the first approach using the URL parameter version, but if I do can I still keep track of play score using your Player Data Modual? It’s one of the requirements to keep track of what items they explore. (your demos are great, I’m just little overwhelmed.)

Hi @Bill_Sullivan yes, you can still use the Player Data Module regardless of the approach you take here.

The URL param method is generally better for use cases where a user only views one scene at a time - switching requires a page reload (and therefore permission prompts each reload) whereas the react approach is better for use cases where a user will be switching between scenes in the same session (browser permissions only once)

My issue is I’m already over loaded with deliverables to take on learning how to do UI design in React. I’m now just getting the first approach working and it’s straightforward for me, while just looking into Reach and how I’d have to make UI elements is so different from what I’m used too… I have over 25 years experience but with only a month left I’m down to the wire. (www.pakobrats.com my personal portfolio, check out the museum projects) this one is gonna be awesome, have some beautiful virtual kiosk’s going, with clickable element showing video and text and stuff

Hey Tony,

Switched back to REACT multi scene routing, got it working. Added my player data module, got it working. I would like to not use the button page supplied with the multi scene demo, how would I call a scene change form a custom button overlaid on a page similar to the logbook button works? And Could I also make the call to change scenes from an object in the scene when clicked? Sorry if this is a lot to ask, just figuring things out. P.S. this is a great tool for opmizing GLBs getting more incredable KB savings using this page. https://optimizeglb.com/

Hello @Bill_Sullivan If you have a new/seperate 8th Wall question I would suggest opening up a new technical support thread so that topics are more easily searchable and better organized for the community.

Thanks Ian, got it. I’ll get into the habit of making new topics

1 Like