Skip to content

Commit

Permalink
docs(pitfalls): mention NaN camera
Browse files Browse the repository at this point in the history
  • Loading branch information
philpax committed Sep 20, 2023
1 parent bf4215c commit 4c8908d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/src/reference/common_pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,24 @@ To fix this, use a random `Vec3` for your color and then extend it to a `Vec4`:
let color = rand::random::<Vec3>().extend(1.0);
```

# My character controller is unaffected by gravity
## My character controller is unaffected by gravity

PhysX, which we use for physics, does not apply gravity to character controllers.

You can account for this by moving the character controller down yourself;
an example of this can be found in [the `character_movement` standard package](https://github.com/AmbientRun/Ambient/blob/main/guest/rust/packages/std/character_movement/src/server.rs)
which maintains a `vertical_velocity` component and uses it to simulate gravity.

## My camera's view matrix is all NaNs

This can happen when the transformation used to position the camera in the world is invalid.

There are several potential causes, including:

- The camera is positioned at the origin, and is looking at the origin.
- The camera's `lookat_up` vector is parallel to the `lookat_target` vector. This can happen by default if your `lookat_target` is above or below the camera as `lookat_up` defaults to +Z.
- There is a division by zero somewhere in the camera's transformation. This could happen if your gameplay code for controlling the camera does not account for the possibility of a zero denominator (i.e. no time passing, or no distance travelled).

## Fails to start on Linux (Error in `Surface::configure: parent device is lost`)

If you're running Wayland, you may have to start ambient with: `WAYLAND_DISPLAY=wayland-1 ambient run`.
Expand Down

0 comments on commit 4c8908d

Please sign in to comment.