Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucaspoffo/shipyard_rapier
Physics plugin with rapier for the shipyard ECS.
https://github.com/lucaspoffo/shipyard_rapier
ecs physics rapier shipyard
Last synced: 3 months ago
JSON representation
Physics plugin with rapier for the shipyard ECS.
- Host: GitHub
- URL: https://github.com/lucaspoffo/shipyard_rapier
- Owner: lucaspoffo
- License: mit
- Created: 2021-02-02T05:33:38.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-21T19:38:24.000Z (almost 4 years ago)
- Last Synced: 2024-10-29T22:47:22.681Z (3 months ago)
- Topics: ecs, physics, rapier, shipyard
- Language: Rust
- Homepage:
- Size: 229 KB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shipyard Rapier
Physics plugin with [rapier](https://github.com/dimforge/rapier) for the [shipyard](https://github.com/leudz/shipyard) ECS.
2D: [![Crates.io](https://img.shields.io/crates/v/shipyard_rapier2d)](https://crates.io/crates/shipyard_rapier2d)
[![Documentation](https://docs.rs/shipyard_rapier2d/badge.svg)](https://docs.rs/shipyard_rapier2d)3D: [![Crates.io](https://img.shields.io/crates/v/shipyard_rapier3d)](https://crates.io/crates/shipyard_rapier3d)
[![Documentation](https://docs.rs/shipyard_rapier3d/badge.svg)](https://docs.rs/shipyard_rapier3d)## How to use
Setup the physics in the shipyard world:
```rust
let world = World::new();
world.run(setup_physics).unwrap();
```Create an body and a collider component, add those to an existent entity, or create a new one:
```rust
let body = RigidBodyBuilder::new_dynamic().translation(x, y);
let collider = ColliderBuilder::cuboid(rad, rad).density(1.0);
all_storages.add_entity((body, collider));
```In your gameplay loop, execute the physics systems to simulate the world:
```rust
// Create rapier colliders, bodies and joints based on the shipyard components.
world.run(create_body_and_collider_system).unwrap();
world.run(create_joints_system).unwrap();// Step the world based on a frame rate.
let frame_time = 60.0 / 1000.0; // 60 fps simulation
world.run_with_data(step_world_system, frame_time).unwrap();// Remove any physics components from deleted entities.
world.run(destroy_body_and_collider_system).unwrap();
```This plugin is based of [bevy_rapier](https://github.com/dimforge/bevy_rapier/) plugin.