bevy-relationships

Document Bevy entity relationships and traversal mechanisms with Rust examples.

125|10|Updated Nov 22, 2022
One-click install
npx skills add https://github.com/nolantait/bevy-starter --skill bevy-relationships
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: bevy-relationships
Source: https://github.com/nolantait/bevy-starter/tree/main/.agents/skills/bevy-relationships
Command: npx skills add https://github.com/nolantait/bevy-starter --skill bevy-relationships

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide provides a clear reference for Bevy ECS entity relationships (ChildOf/Children), custom relationships with Relationship and RelationshipTarget, and patterns for spawning and traversing related entities.

Core Features & Use Cases

  • Built-in parent/child synchronization and despawning behavior (ChildOf/Children)
  • Custom relationships with Relationship and RelationshipTarget, including linked spawning
  • Spawning, querying, and traversing relationships with with_children, iter_ancestors, and iter_descendants
  • Real-world usage examples for Bevy 0.19 in project architectures

Quick Start

Apply these patterns to implement and test Bevy entity relationships in a Bevy 0.19 project.

Frequently Asked Questions about bevy-relationships

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create custom entity relationships in Bevy ECS?▼

Custom entity relationships in Bevy ECS are built using the Relationship and RelationshipTarget traits, allowing you to define and synchronize custom hierarchical links beyond built-in parent/child components.

What is the difference between ChildOf and Children in Bevy?▼

ChildOf and Children in Bevy represent built-in parent/child entity relationships. ChildOf marks the child entity, while Children is the target component on the parent managing synchronization and despawning behavior.

How do I traverse entity hierarchies in Bevy ECS queries?▼

Entity hierarchy traversal in Bevy ECS queries uses iter_ancestors and iter_descendants functions to programmatically navigate up and down parent/child relationship chains.

Does Bevy 0.19 support linked spawning for entity relationships?▼

Yes, Bevy 0.19 supports linked spawning for entity relationships, providing patterns like with_children to spawn and correctly associate related entities simultaneously.

Why are my Bevy child entities not despawning with their parent?▼

Child entities failing to despawn with their parent often indicates an issue with built-in ChildOf/Children synchronization, which this guide addresses by documenting correct despawning behavior and relationship patterns.