With this example (React + Three + Cannon), I’d like my yellow cube to move only on the X axis without being affected by gravity. However hard I try to compensate for gravity by assigning an opposite force, my cube either rises or falls. The adjustment is extremely fine and I don’t think this is the right solution. The cube starts at position 3 on the Y axis like the instances, but after a certain delay, they fall.
For my instances, I’d like the same principle, except that the movement must be on the Z axis only.
That sounds hard. I would just reset the y position to what I want it to each frame?
Otherwise its literally like trying to fly a helicopter with an algorithm. The physics simulation is running multiple substeps per frame and you’re trying to adjust it one whatever the useFrame interval is, so you’re not going to intercept every force applied to it during the simulation.
Other options might be to set the friction to 0 and let them slide on the ground, or on an invisible box…
Yes, but it’s more difficult, i don’t want to filter the collision in this way.
My Cube has to be on the support. So it always collides with the support. What I want is to recognize the Instance on collision to make the Support disappear and have my Cube fall.
You probably have to research how to set up a collision callback in cannon.
I’m most familiar with ammo.js which gives you a list of “contact pairs” on each simulation substep… which you can loop through and look for a contact between your 2 objects.