Character keeps falling through the floor
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?
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)
That reason is because before load the rigid model, your avatar is pre-rendered.
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`