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

Overview

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.

You might also like...
"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

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

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

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

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

Transform tagged Markdown string to HTML during build time.

tagged-md Transform tagged Markdown string to HTML! Check out the examples! Motivation Have you ever written HTML strings in your JavaScript code? It'

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

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

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

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

Owner
NemuiSen
Un programador que deserto de C++ por Rust por el administrador de paquetes
NemuiSen
2d collision test for game-development in rust (with optional integration and example for bevy)

impacted 2d collision test for game-development in rust (with optional integration and example for bevy) This provides a low-level "narrow-phase" coll

Jonathan Cornaz 17 Nov 5, 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

Niklas Eicker 205 Jan 2, 2023
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;

Ben Reeves 7 Aug 14, 2022
Simple rust asset handling derive macro for enums, and a proc-macro learning resource!

asset-derive Summary • Todos • Docs Summary Simple Rust asset loading derive macro for Enums, and a resource for learning proc-macros! Please feel fre

Shadorain 5 Feb 9, 2023
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

Mika 30 Jan 4, 2023
Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

Adam 7 Oct 4, 2023
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

Lucas Arriesse 125 Dec 31, 2022
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

研究社交 208 Dec 27, 2022
A simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

null 3 May 8, 2023
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Sélène Amanita 11 May 28, 2023