An asset that provides 2d collision detector and kinematics, build from scratch in bevy

Last update: May 20, 2022

Busturi

latest version

A physics engine An asset that provides 2d collision detector and kinematics, build from scratch in bevy

How to use

Add PhysicsPlugin to the program and optionally also DebugPlugin to see the collisions of the entities.

App::new()
	.add_plugins(DefaultPlugins)
	.add_plugin(PhysicsPlugin::default())
	// This plugin allows us to see the collisions
	//.add_plugin(DebugPlugin)

Then after creating an entity with at least the Transform component insert the CollisionShape component to detect the collisions and who it collided with, and if you want insert the KinematicBundle that the entity has physical properties such as speed, acceleration, or strength

commands.spawn_bundle(SpriteBundle {
	sprite: Sprite {
		custom_size: Some(Vec2::splat(100.)),
		color: Color::CYAN,
		..Default::default()
	},
	..Default::default()
})
// The size you pass to ColliderShape::AABB(_, _) should be half what you want
.insert(ColliderShape::AABB(50., 50.));

In the end it should be something similar to the following example

use bevy::prelude::*;
use butsuri::prelude::*;

fn main() {
	App::new()
		.add_plugins(DefaultPlugins)
		.add_plugin(PhysicsPlugin::default())
		.add_system(setup)
	.run();
}

fn setup(mut commands: Commands) {
	commands.spawn_bundle(SpriteBundle {
		sprite: Sprite {
			custom_size: Some(Vec2::splat(100.)),
			color: Color::CYAN,
			..Default::default()
		},
		..Default::default()
	})
	.insert(ColliderShape::AABB(50., 50.));
}

// handle collisions as you want
fn collision(
	mut collision_event: EventReader,
	mut query: Query<&mut Sprite>,
) {
	// ...
}

Examples

  • Collision: a group of sprites that change color when they collide
  • Player Input: similar to the previous example but there is a player that is controlled by applying velocity with the w/a/s/d keys
  • Gravity: shows how to activate and use gravity

How useful is this project compared to other similar ones?

Little, because there are better options that offer more features for example heron or bevy_rapier. I did this project to learn how physics engines work from the inside and i'm a bit lost with things like momentum, but i'll keep updating this project to improve my knowledge, which I'm open to criticism or recommendations.

if you want to contact me you can do it by discord (NemuiSen#4114) on the Bevy server

PS: I'm sorry if something doesn't make sense, I'm using my vague knowledge of English and google translate to write this.

GitHub

https://github.com/NemuiSen/bustsuri
You might also like...

Simple 2d pinball game for testing of bevy and rapier.

Simple 2d pinball game for testing of bevy and rapier.

Pinball2D Using the Bevy game engine and Rapier physics engine for a simple 2D pinball game. pinball2d.mov Wrote a short piece about how the game was

Apr 15, 2022

Plotting library for the Bevy game engine with a focus on esthetics and interactivity

Plotting library for the Bevy game engine with a focus on esthetics and interactivity

Plotting library for the Bevy game engine with a focus on esthetics and interactivity. It can handle both data points (see the "minimal", "markers", a

May 24, 2022

Helper functions and structs for working with 2D space in Bevy.

About Baffled by quaternions? Want to accelerate an object in 2D? Wish that there was a simple way to work with grids? Just want to know if two axis-a

May 9, 2022

Integration layer between Bevy, puffin and tracing libraries

bevy_puffin This crate integrates the puffin library into Bevy. It provides PuffinTracePlugin to use as a replacement for the Bevy's default LogPlugin

May 12, 2022

State of the art "build your own engine" kit powered by gfx-hal

State of the art

A rendering engine based on gfx-hal, which mimics the Vulkan API. Building This library requires standard build tools for the target platforms, except

May 18, 2022

A Bevy plugin for loading the LDtk 2D tile map format.

A Bevy plugin for loading the LDtk 2D tile map format.

bevy_ldtk ( Tileset from "Cavernas" by Adam Saltsman ) A Bevy plugin for loading LDtk tile maps. Usage use bevy::prelude::*; use bevy_ldtk::*; fn mai

Apr 21, 2022

Basic first-person fly camera for the Bevy game engine

bevy_flycam A basic first-person fly camera for Bevy 0.4 Controls WASD to move horizontally SPACE to ascend LSHIFT to descend ESC to grab/release curs

May 17, 2022

An ergonomic physics API for bevy games.

Heron An ergonomic physics API for 2d and 3d bevy games. (powered by rapier) How it looks like fn main() { App::build() .add_plugins(DefaultPlug

May 18, 2022

Inspector plugin for the bevy game engine

Inspector plugin for the bevy game engine

bevy-inspector-egui This crate provides the ability to annotate structs with a #[derive(Inspectable)], which opens a debug interface using egui where

May 21, 2022
Bevy plugin helping with asset loading and organisation

Bevy asset loader This Bevy plugin reduces boilerplate when loading game assets. The crate offers the AssetCollection trait and can automatically load

May 19, 2022
A Rust library for reading asset files and resource packs for any version of Minecraft

minecraft-assets A Rust library for reading asset files and resource packs for any version of Minecraft. Example use minecraft_assets::api::AssetPack;

Mar 23, 2022
Rapidly iterate and build Bevy UI's with existing web-based technologies
Rapidly iterate and build Bevy UI's with existing web-based technologies

bevy_webview WIP   Rapidly iterate and build Bevy UI's with existing web-based technologies It is currently very early days of this plugin - only Linu

May 16, 2022
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

May 10, 2022
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

May 25, 2022
"putzen" is German and means cleaning. It helps keeping your disk clean of build and dependency artifacts safely.

Putzen "putzen" is German and means cleaning. It helps keeping your disk clean of build and dependency artifacts safely. About In short, putzen solves

Jan 31, 2022
virtualization-rs provides the API of the Apple Virtualization.framework in Rust language.
virtualization-rs provides the API of the Apple Virtualization.framework in Rust language.

virtualization-rs Rust bindings for Virtualization.framework virtualization-rs provides the API of the Apple Virtualization.framework in Rust language

Apr 13, 2022
Provides a mechanism to lay out data into GPU buffers according to WGSL's memory layout rules

Provides a mechanism to lay out data into GPU buffers ensuring WGSL's memory layout requirements are met. Features supports all WGSL host-shareable ty

May 8, 2022
Pixel-Perfect, 2D Renderer for Bevy that Seamlessly Targets Desktop and Web
Pixel-Perfect, 2D Renderer for Bevy that Seamlessly Targets Desktop and Web

bevy_retro ( Screenshot of Bounty Bros. game made with Bevy Retro and Skip'n Go ) Bevy Retro is a 2D, pixel-perfect renderer for Bevy that can target

May 24, 2022
A quick and dirty Space Invaders type game in Bevy, with attached tutorial.

This article is in-development and will be released in full form soon. It'll appear on Medium (my publisher likes that), with this as a the accompanyi

Feb 5, 2022