• Stars
    star
    203
  • Rank 192,890 (Top 4 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A floating character controller for Bevy

Build Status Latest Version Rust Documentation Rust Documentation

Tnua - A Character Controller for Bevy.

Tnua ("motion" in Hebrew) is a floating character controller, which means that instead of constantly touching the ground the character floats above it, which makes many aspects of the motion control simpler.

Tnua can use Rapier or XPBD, and supports both the 2D and 3D versions of both with integration crates:

Note that:

  • Both integration crate (bevy-tnua-<physics-backend>) and the main bevy-tnua crate are required, and that the main plugin from both crates should be added.
  • If you use a physics backend with double precision (like XPBD with the f64 flag), you need to add the f64 flag to all the Tnua crates. This applies to double precision data that gets defined by the physics backend - Bevy itself will still use single precision, and this is the precision the position and rotation will use.

Features

  • Supports both 2D and 3D versions of Rapier and XPBD
  • Running
  • Jumping
  • Crouching
  • Variable height jumping
  • Coyote time
  • Jump buffer
  • Running up/down slopes/stairs
  • Tilt correction
  • Moving platforms
  • Rotating platforms
  • Animation helpers (not the animation itself, but Tnua has facilities that help deciding which animation to play)
  • Jump/fall through platforms
  • Air actions

Demos:

Running the Demos Locally

$ cargo run --bin <demo-name> --features <physics-backend>

Where <demo-name> is the name of the demo and <physics-backend> is either rapier2d, rapier3d, xpbd2d or xpbd3d. Make sure to match the dimensionality of the backend (2D or 3D) to that of the demo. For example, to run the 3D platformer with XPBD, use this:

$ cargo run --bin platformer_3d --features xpbd3d

Interesting Parts of the Demo Code

Versions

Tnua is broken into different crates that update separately, so this is broken into multiple tables. The version of bevy-tnua-physics-integration-layer must be the same for both the main bevy-tnua crate and the integration crates.

Main

bevy bevy-tnua-physics-integration-layer bevy-tnua
0.13 0.3 0.16
0.13 0.2 0.15
0.12 0.1 0.13-0.14

Rapier integration

bevy bevy-tnua-physics-integration-layer bevy-tnua-rapier bevy_rapier
0.13 0.3 0.4, 0.5 0.25
0.13 0.2 0.3 0.25
0.12 0.1 0.2 0.24
0.12 0.1 0.1 0.23

XPBD integration

bevy bevy-tnua-physics-integration-layer bevy-tnua-xpbd bevy_xpbd
0.13 0.3 0.3, 0.4 0.4
0.13 0.2 0.2 0.4
0.12 0.1 0.1 0.3

Pre-split

bevy bevy-tnua bevy_rapier
0.12 0.12 0.23
0.11 0.8 - 0.11 0.22
0.10 0.1 - 0.7 0.21

Reference Material

The following were used for coding the math and physics of Tnua:

Alternatives

  • bevy_mod_wanderlust - the original inspiration for this mod, and where I got the floating capsule video from. I ended up creating my own plugin because bevy_mod_wanderlust does not support 2D.
  • Rapier itself has a character controller. It's not a floating character controller, but it's integrated with the physics engine itself and uses that privilege to work out some of the problems the floating model is used to address.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

More Repositories

1

rust-typed-builder

Compile-time type-checked builder derive
Rust
847
star
2

vim-vebugger

Yes, we do need another debugger plugin
Vim Script
425
star
3

vim-merginal

Fugitive extension to manage and merge Git branches
Vim Script
277
star
4

bevy-yoleck

Your Own Level Editor Creation Kit
Rust
172
star
5

rust-smart-default

Rust macro for automatically generating default
Rust
126
star
6

vim-dutyl

Coordinate D tools to work together for you
Vim Script
79
star
7

vim-smile

The power of :smile available to everyone
Vim Script
30
star
8

bevy-egui-kbgp

Better keyboard and gamepad story for egui in Bevy
Rust
20
star
9

nvim-moonicipal

Task runner with focus on rapidly changing personal tasks
Lua
15
star
10

nu_plugin_skim

Rust
14
star
11

woab

Widgets on Actors Bridge - a GUI microframework for combining GTK with Actix
Rust
14
star
12

vim-yankitute

regex powered yank+substitute
Vim Script
13
star
13

vim-makecfg

Database of `makeprg` and `errorformat` settings
Vim Script
13
star
14

vim-casetrate

Modify the case of identifiers
Vim Script
11
star
15

vimConfig

My vim configurations
Lua
11
star
16

rust-powerset-enum

Rust
11
star
17

nvim-impairative

Lua
11
star
18

vim-omnipytent

The all powerful Pythonic task runner
Python
10
star
19

nvim-buffls

Add LSP functionality to specific Neovim buffers
Lua
9
star
20

bevy-yoetz

Rust
8
star
21

rust-inherent-pub

Rust
7
star
22

vim-erroneous

The right way to handle errors
Vim Script
7
star
23

nvim-channelot

Operate Neovim jobs from Lua coroutines
Lua
6
star
24

breeze.vim

Html navigation like vim-easymotion, tag matching, tag highlighting and DOM navigation
Python
6
star
25

nvim-days-without

Lua
6
star
26

nvim-blunder

Run commands in the builtin terminal and parse their output to the quickfix list
Lua
4
star
27

vim-integrake

Abuse Rake to do project chores around Vim
Ruby
3
star
28

vim-tabnine-completefunc

A TabNine completefunc for Vim
Vim Script
2
star
29

vim-terminalogy

Show and tell with a shell
Vim Script
2
star
30

sidekick-jam-entry-danger-doofus

Rust
1
star
31

kosem

Test wizard for semi-automatic testing
Rust
1
star
32

rust-poc-macro-emit-data

Rust
1
star
33

bevy-game-jam-1-entry

Rust
1
star