1

I'm making an A-Frame project which will allow users to interact with math models. I'm using the aframe-super-hands-component with aframe-physics-extras for its nice "sleep" effect. To add a layer of control, I'm trying to make it so that the user can use a controller's joysticks to bring a model closer/farther away from the controller, similar to the Oculus Dash controls (https://youtu.be/sMjlM5vFSA0?t=1m55s).

However, when I try to update a model's position, as my model entities are defined as dynamic bodies, they don't move. I know that I can remove the dynamic-body component, move the body, and then reattach dynamic-body, but I want to avoid that as I'm planning to move models in tick. Is there a way I can move a dynamic body without breaking dynamic-body behavior?

Here's a link to an example which tries to update a box's position: https://codepen.io/kchen1250/pen/MBmRYo

Kevin
  • 19
  • 8

1 Answers1

2

You can sync the position of the entity and the dynamic-body using the dynamic-bodys method syncToPhysics()

el.components["dynamic-body"].syncToPhysics()

like i did here.


There is also an analogous syncFromPhysics() if you'd ever need it.
Piotr Adam Milewski
  • 14,150
  • 3
  • 21
  • 42
  • I tried this, and it kinda works. In my main project where I can grab an object with a controller, the object does try to move, but can't get very far: https://imgur.com/a/AfzmwzL – Kevin Jul 24 '18 at 15:50
  • Update: I think your answer is right, i think the weird behavior above is caused by the `super-hands` grab event being triggered while trying to update the position – Kevin Jul 24 '18 at 15:57
  • Follow up question: any way to supress super-hand's grab to move a grabbed object? – Kevin Jul 24 '18 at 16:00
  • @kchen1250 i'm quite unable to test the super hands right now, id suggest making a new question for this matter – Piotr Adam Milewski Jul 24 '18 at 18:30
  • @PaulSlm glad I could help :) – Piotr Adam Milewski Jan 26 '21 at 18:37