Hi guys! I’m trying to do some basic stuff in @react-three/rapier
. What my intension was to make a box floor and onclick of a button throw some other small cubes at the floor just like this: floor-and-balls. I’ve just started the development and met with an error which is I have made the floor and small cubes too but when its only one cube its falling down. but when its array of cubes its simply stays in the air. can someone plz look into it. Thank you
My sandbox Link : rapierPracticerapier-practice - CodeSandbox
It’s working as expected now,
What my mistake was I had put my mapped array into a single <RigidBody>
like:
.....
<RigidBody>
{BoxArray.map((currentBox, index) => {
return (
<Box key={index} position={currentBox} args={[2, 1, 2]}>
<meshLambertMaterial color="hotpink" />
</Box>
);
})}
</RigidBody>
....
when I changed it to something like this:
{BoxArray.map((currentBox, index) => {
return (
<RigidBody key={index}>
<Box position={currentBox} args={[2, 1, 2]}>
<meshLambertMaterial color="hotpink" />
</Box>
</RigidBody>
);
})}
Its working fine.