ecctrl icon indicating copy to clipboard operation
ecctrl copied to clipboard

Character keeps falling through the floor

Open TyByers21 opened this issue 1 year ago • 3 comments

I'm having a problem with my character always falling through the floor no matter where I position the character or the ground. everything is setup as a trimesh in rapier. Is anyone else having this issue?

TyByers21 avatar Oct 07 '24 07:10 TyByers21

it happened to me when the character was suppose to stand on a rigidbody of a loaded model. if there is no suspense (react) and the model will not load in time, the character will fall through. also make sure ccd is on for the trimesh and that the character has a "falling" on start (or position it slightly above where it should stand)

elisherer avatar Oct 07 '24 07:10 elisherer

That reason is because before load the rigid model, your avatar is pre-rendered.

madspace1112 avatar Oct 17 '24 17:10 madspace1112

i use this code, it works : ``` <Physics debug={DEBUG} timeStep="vary" paused={!start}> <PhysicsController onReady={() => { console.log("启动物理引擎"); setStart(true); }} /> ...

const PhysicsController = ({ onReady }: { onReady: () => void }) => { const { world } = useRapier(); useEffect(() => { if (world) { // 物理预热逻辑 const warmup = () => { for (let i = 0; i < 5; i++) world.step(); onReady(); }; // 延迟执行确保完全初始化 setTimeout(warmup, 50); } }, [world]);

return null; };

you can change  step number in function` warmup`

golden-fruit avatar May 09 '25 16:05 golden-fruit