pmndrs / use-cannon

👋💣 physics based hooks for @react-three/fiber
https://cannon.pmnd.rs
2.76k stars 154 forks source link

Collision Logic Stopped Working #234

Closed prarabdhb closed 3 years ago

prarabdhb commented 3 years ago

The collision logic has started behaving unexpectedly after I upgraded from 2.2.1 to 2.5.0

On further inspection, the issue starts happening after this commit https://github.com/pmndrs/use-cannon/commit/cd7427705506fea3bb700e4a748dbee8271e67af

Are we expected to change something to ensure that the collision logic works after this commit? Couldn't find anything in the Readme or Release Notes

drcmda commented 3 years ago

i think the only impact of that change is that it uses matrix and matrixautoupdate=false instead of pos/rot. collisions must work, all the examples have collisions working. could you make a quick repro?

prarabdhb commented 3 years ago

I further tried to figure out the error. The collision works fine actually. After collision, I change the position of a Sphere. I use a Vector3 to change the position of the sphere. The difference is that earlier z = 0 was a different point in my scene, and after this upgrade, the z = 0 point has changed, therefore the calculations don't work as I expect them to work. (If I add a specific offset to my z variable calculations, the behavior returns to normal)

Could there be any change with respect to this in this commit?

drcmda commented 3 years ago

how do you change the position of the sphere? by just calling object.current.position.set(...) ?

prarabdhb commented 3 years ago

Yes, we follow this method.

prarabdhb commented 3 years ago

Hi, any help on this?

stockhuman commented 3 years ago

Hi @prarabdhb, to better help you, a codesandbox that reproduces your z-offset issue would help. As mentioned, examples found in this library haven't suffered from this issue you're facing between versions.

stockhuman commented 3 years ago

Closing as irreproducible / unlikely a bug.