Skip to content

Instantly share code, notes, and snippets.

View GianpaoloBranca's full-sized avatar
🏠
Working from home

GianpaoloBranca

🏠
Working from home
View GitHub Profile
@GianpaoloBranca
GianpaoloBranca / cloneEntity.rs
Last active April 8, 2023 04:52
Copy all components from an Entity to another in Bevy
// Bevy version: 0.10
use bevy::{prelude::*, ecs::system::Command};
// Copy all components from an entity to another.
// Using an entity with no components as the destination creates a copy of the source entity.
// panics if
// - the components are not registered in the type registry,
// - the world does not have a type registry
// - the source or destination entity do not exist
pub fn clone_entity_components(world: &mut World, source: Entity, destination: Entity) {