Git Product home page Git Product logo

bevy_mod_physx's Introduction

ย 

Bevy plugin for PhysX 5

PhysX is an open-source Physics SDK written in C++ and developed by Nvidia.
This crate is a bridge between Bevy ECS and Rust bindings made by Embark Studios.

github docs.rs crates.io

Getting started

Here is a snippet, which creates a ball bouncing on a fixed ground.

// this is similar to basic simulation example in rapier3d
use bevy::prelude::*;
use bevy_mod_physx::prelude::*;
use bevy_mod_physx::prelude::{Material, Shape}; // bevy prelude conflicts

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(PhysicsPlugins)
        .add_systems(Startup, setup_graphics)
        .add_systems(Startup, setup_physics)
        .insert_resource(DebugRenderSettings::enable())
        .run();
}

fn setup_graphics(mut commands: Commands) {
    // Add a camera so we can see the debug-render.
    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(-3.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..Default::default()
    });
}

fn setup_physics(
    mut commands: Commands,
    mut physics: ResMut<Physics>,
    mut geometries: ResMut<Assets<Geometry>>,
    mut materials: ResMut<Assets<Material>>,
) {
    // Create the ground.
    commands.spawn((
        RigidBody::Static,
        Shape {
            geometry: geometries.add(Geometry::halfspace(Vec3::Y)),
            material: materials.add(Material::new(&mut physics, 0.5, 0.5, 0.6)),
            ..default()
        },
        SpatialBundle::from_transform(Transform::from_xyz(0.0, -2.0, 0.0)),
    ));

    // Create the bouncing ball.
    commands.spawn((
        RigidBody::Dynamic,
        Shape {
            geometry: geometries.add(Geometry::ball(0.5)),
            material: materials.add(Material::new(&mut physics, 0.5, 0.5, 0.6)),
            ..default()
        },
        SpatialBundle::from_transform(Transform::from_xyz(0.0, 4.0, 0.0)),
    ));
}

Compatibility / Prior art

published 0.4.x Bevy 0.12 PhysX 5
0.2.x - 0.3.x Bevy 0.11 PhysX 5
git tags git:master Bevy 0.12 PhysX 5
git:a2741a6 Bevy 0.11 PhysX 5
git:a21b570 Bevy 0.11 PhysX 4
git:43ae89e Bevy 0.10 PhysX 5
git:8f66a99 Bevy 0.10 PhysX 4
other crates bevy_mod_physx v0.1.0 Bevy 0.10 deprecated
bevy_prototype_physx Bevy 0.2-0.5 unknown
bevy_physx never existed

Note: you can find PhysX 4 version of this crate. It exists because PhysX 5 bindings don't have Vehicle API. It is not officially supported nor published to crates.io, and may get removed in the future.

bevy_mod_physx's People

Contributors

rlidwka avatar latentspaceexplorer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.