-
Hi, this may seem like a weird question, but I have 2 box objects and I'd like to use onCollide to detect if they are touching, but prevent them from physically bouncing against each other. I'd like to handle the behavior of collision myself, after using the cannon events to detect them. I guess what I'm looking to do is like a hit-box, or something around my component to detect collisions without the inner boxes really touching yet. Right now, it's like the collision is only detected if the middles of the boxes are touching, and by then they are bumping into each other and I want to prevent that. I'm using blocks like this const [ref, api] = useBox(() => ({
onCollide: () => {
console.log("colliding");
},
onCollideBegin: () => {
console.log("start collision");
},
mass: 1,
position: [currentPosition.x, size / 2, currentPosition.z],
})); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Beta Was this translation helpful? Give feedback.
It seems to work better now that I added
type: "Kinematic",
to my useBox declaration. The boxes no longer fling each other everywhere, but they still don'tonCollideBegin
until they're overlapping a lot. Any idea how I can expand that? See screenshotIt'a like there's a tiny box in the center that's actually getting collided with
Any tips for a collider size that visually matches the mesh?