Skip to content

Commit

Permalink
fix physics docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Jul 16, 2024
1 parent 2cbba55 commit 39ac127
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/docs/guides/PHYSICS.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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])
```

Expand All @@ -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)
Expand Down

0 comments on commit 39ac127

Please sign in to comment.