Skip to content

Collider transform props / debug issue. #728

Description

@igpdev-428

Hi! I'm new to the whole ecosystem. Thank you for all the work and incredible tools I've been finding out.

I'm trying to work with colliders: I have a basic player with a rigidbody and a capsule collider inside. Gravity is turned on. The ground also has a collider and I'm testing several colliders that spawn according to the bounding box size of several meshes in the scene.

ISSUE: When I set some of the props for either the RigidBody or CuboidCollider scale property for the rigidbody in some cases the colliders stop working and it falls through the ground, or it doesn't collide at all. The debug shows the colliders at the right spot.

I've tried several changes, taking the collider out, in, automatic colliders from the rigidbody, etc. Outside of the mesh, inside, etc. Sometimes it works sometimes it doesn't. Usually I can only guarantee collission If I just spawn rigidbody and cuboidcollider without props.

It's pretty sporadic but there are several cases where the debug physics shows a collision should stop movement but it still goes through.

This following example has me confused and it's the same issue but a specific case.

export function MeshWithCollider(props: meshPropsPlus) {
  const colliderSize = new Vector3()
  const colliderCenter = new Vector3()
  props.geometry.boundingBox?.getSize(colliderSize)
  props.geometry.boundingBox?.getCenter(colliderCenter)

  const { position, rotation, scale, ...filteredProps } = props
  console.log('AAA', props.scale)
  return (
    <>
      <mesh {...props} />
      <RigidBody position={props.position} scale={-1.15} type={'fixed'} colliders={false}>
        <CuboidCollider
          position={colliderCenter}
          scale={-1.15} /* this works */
           /*  scale={+1.15}  /* this doesn't , and debug wireframe stays same spot */ */
          args={[colliderSize.x / 2, colliderSize.y / 2, colliderSize.z / 2]}
        />
      </RigidBody>
    </>
  )
}

The scale on the CuboidCollider doesn't affect the box helper that comes with the physics debug flag , but it does cancel the collision when it doesn't coincide in sign with the parent (or when it is missing from the CuboidCollider element). I'm pretty much lost at this point. I have a feeling that the debug mode is not updating correctly with the transform of the CuboidCollider but it's a guess.

Versions used:
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"@react-three/rapier": "^1.5.0",
"@react-three/drei": "^9.121.4",
"@react-three/fiber": "^8.17.14",
"@react-three/handle": "^6.6.2",
"@react-three/postprocessing": "^2.19.1",

"@react-three/uikit": "^0.8.7",
"@react-three/uikit-apfel": "^0.8.7",
"@react-three/xr": "^6.6.2",
"@types/three": "^0.172.0",
"@vitejs/plugin-react-swc": "^3.7.2",
"iwer": "^2.0.0",
"leva": "^0.10.0",

"three": "^0.173.0",
"vite-tsconfig-paths": "^5.1.4"

},

Thank you in advance and also please ask for any context information I might've missed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions