Rust - Avian

Introduction

Avian is an ECS-based 2D and 3D physics engine for Bevy, a refreshingly simple data-driven game engine built in Rust. Avian prioritizes ergonomics and modularity, with a focus on providing a native ECS-driven user experience.

Getting Started

Getting up to speed with Avian is very straightforward!

First, add it as a dependency in Cargo.toml:

[dependencies]
avian2d = "0.5" # For 2D applications
avian3d = "0.5" # For 3D applications
bevy = "0.18"

Then, add PhysicsPlugins to your Bevy application:

use avian3d::prelude::*;
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, PhysicsPlugins::default()))
.run();
}

Now, you can use the numerous components and resources provided by Avian to add physics behavior to your entities.

For example, turning an entity into a rigid body with a collider is as simple as adding the RigidBody and Collider components, and an initial velocity can be specified using LinearVelocity:

use avian3d::prelude::*;
use bevy::prelude::*;
fn setup(mut commands: Commands) {
commands.spawn((
RigidBody::Dynamic,
Collider::sphere(0.5),
LinearVelocity(Vec3::X),
));
}

Pending

https://joonaa.dev/blog/06/avian-0-1