{"id":16224694,"url":"https://github.com/bamling/amethyst-nphysics-example","last_synced_at":"2025-10-05T07:58:51.588Z","repository":{"id":189716781,"uuid":"185256935","full_name":"bamling/amethyst-nphysics-example","owner":"bamling","description":"nphysics Amethyst integration in Rust","archived":false,"fork":false,"pushed_at":"2019-05-30T09:22:12.000Z","size":203,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T02:41:20.851Z","etag":null,"topics":["game-development","game-engine","gamedev","physics","physics-engine","rust","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bamling.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-05-06T19:15:00.000Z","updated_at":"2021-01-30T18:36:02.000Z","dependencies_parsed_at":"2023-08-21T14:05:34.168Z","dependency_job_id":null,"html_url":"https://github.com/bamling/amethyst-nphysics-example","commit_stats":null,"previous_names":["bamling/amethyst-nphysics-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bamling/amethyst-nphysics-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamling%2Famethyst-nphysics-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamling%2Famethyst-nphysics-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamling%2Famethyst-nphysics-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamling%2Famethyst-nphysics-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bamling","download_url":"https://codeload.github.com/bamling/amethyst-nphysics-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamling%2Famethyst-nphysics-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278425490,"owners_count":25984687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game-development","game-engine","gamedev","physics","physics-engine","rust","rust-lang"],"created_at":"2024-10-10T12:25:13.830Z","updated_at":"2025-10-05T07:58:51.571Z","avatar_url":"https://github.com/bamling.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# amethyst-nphysics-example\n\nSimple example *\"game\"* illustrating how an integration of [nphysics](https://www.nphysics.org/)  into [Amethyst](https://amethyst.rs/) could look like. This example uses the `master` version of Amethyst and has all the nphysics related logic abstracted away in a separate crate (`game_physics`).\n\nRust version:\n`rustc 1.36.0-nightly (3991285f5 2019-04-25)`\n\n#### Running the example:\n\nClone the repository:\n```bash\n$ git clone https://github.com/bamling/amethyst-nphysics-example.git\n```\n\nChange into the checkout directory:\n```bash\n$ cd amethyst-nphysics-example\n```\n\nExecute [Cargo](https://doc.rust-lang.org/cargo/):\n```bash\n$ cargo run\n```\n\n#### Roadmap:\n\n- [x] Allow multiple `PhysicsCollider`s per `Entity`\n- [x] Allow `PhysicsCollider`s without `PhysicsBody`\n- [x] Automatically apply margin to full `Shape` size\n- [ ] Add more `Shape`s\n- [ ] Add other debug shapes\n- [ ] Expose channels for `CollisionEvent`s and `ProximityEvent`s \n- [x] Remove custom `Isometry`, `Matrix` and `Point` types\n- [ ] Refactor body/collider `Sytem`s\n- [ ] Ray interferences to prevent tunneling issues*\n- [ ] Custom `GameData` with separate dispatcher for movement/physics based `System`s (executed during `fixed_update(..)`)\n- [x] Clean up `game_physics` crate exports\n- [ ] Add tests\n- [ ] Introduce generic type parameters over `f32`\n- [ ] Examples on how to use the crate\n- [ ] Polishing, polishing, polishing...\n- [ ] Build automation/CI\n- [ ] Publish to [crates.io](https://crates.io) (migrate repository for that?)\n\n\n\n\\*Thanks to [sebcrozet](https://github.com/sebcrozet) for the idea:\n\u003e Well, you can cast a ray on the world using: https://www.nphysics.org/rustdoc/nphysics3d/world/struct.ColliderWorld.html#method.interferences_with_ray. The ray direction would be the player desired velocity, and the ray starting point would be right in front of the player in that direction. If interferences are found, then find the one with the smallest toi field: https://www.ncollide.org/rustdoc/ncollide3d/query/ray_internal/struct.RayIntersection.html#structfield.toi which is \u003c 1.0. Then you take this toi (if it exists) and multiply it with the players' desired velocity. This will give you a new vector that is the velocity you actually want to apply to your player.\n\n```rust\nlet point_in_front_of_the_player = desired_velocity.normalize() * (player_box_radius + 0.1) + player_center_position;\nlet ray = Ray::new(point_in_front_of_the_player, desired_velocity);\nlet toi = world.interferences_with_ray(ray, CollisionGroups::default()).fold(1.0, |a, inter| a.min(inter.1.toi));\nlet velocity_to_apply = desired_velocity * toi;\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamling%2Famethyst-nphysics-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbamling%2Famethyst-nphysics-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamling%2Famethyst-nphysics-example/lists"}