From 39ac12749497848db83f79cbf99d26e90d0085ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Tue, 16 Jul 2024 15:47:41 +0200 Subject: [PATCH] fix physics docs --- docs/docs/guides/PHYSICS.mdx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/docs/guides/PHYSICS.mdx b/docs/docs/guides/PHYSICS.mdx index 0ac21a83..3b6a1d48 100644 --- a/docs/docs/guides/PHYSICS.mdx +++ b/docs/docs/guides/PHYSICS.mdx @@ -91,11 +91,12 @@ const rigidBody = useRigidBody({ We need to simulate physics every frame: ```tsx -const renderCallback = useCallback(() => { +const renderCallback = useCallback(({ timeSinceLastFrame }) => { "worklet" - // This updates the world at 60Hz/60 FPS - world.stepSimulation(1 / 60, 1, 1 / 60) + // This updates the world at 60Hz/60 FPS. If our actual frame rate + // is different stepSimulation will interpolate the physics. + world.stepSimulation(timeSinceLastFrame, 1, 1 / 60) }, [world]) ``` @@ -105,10 +106,10 @@ Now that the physical world has been updated we need to update the transform of The `transformManager` has a convenience method for that: ```tsx -const renderCallback = useCallback(() => { +const renderCallback = useCallback(({ timeSinceLastFrame }) => { "worklet" - world.stepSimulation(1 / 60, 1, 1 / 60) + world.stepSimulation(timeSinceLastFrame, 1, 1 / 60) // Update our entity: transformManager.updateTransformByRigidBody(entity, rigidBody)