bevy-resources

Define, insert, initialize, access, update, and remove Bevy Resources as global state.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Bevy Resources are global state used across systems; this reference clarifies how to define, insert, initialize, read, and remove resources to keep data synchronized and lifecycle predictable.

Core Features & Use Cases

  • Define a Resource with the Resource derive
  • Insert, init and read/write to global data across systems
  • Remove resources and handle optional resources to avoid panics
  • Provides practical Bevy ECS patterns for managing global state

Quick Start

Define your resource type and wire it into the Bevy App with insert_resource or init_resource, then access and modify it from systems.

Frequently Asked Questions about bevy-resources

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

FAQPage Schema
How do I define and manage global state in Bevy ECS?

To manage global state in Bevy ECS, define a struct with the Resource derive, then insert or initialize it into the App to share data like scores or settings across systems.

What is the difference between insert_resource and init_resource in Bevy?

insert_resource adds a pre-existing resource instance to the Bevy App, while init_resource registers a resource type with its default value, making it available for systems to access and mutate.

How do I access an optional resource in a Bevy system without panicking?

To access an optional resource in Bevy without panicking, query the resource using an Option wrapper, allowing systems to safely handle cases where the global state has not been initialized or inserted yet.

When should I use Bevy resources versus components for game data?

Use Bevy resources for global data like caches or settings that needs synchronization across systems, whereas components should be used for entity-specific data within the game's ECS architecture.

How do I update and remove a Bevy resource during the game lifecycle?

Update a Bevy resource by mutably accessing it within a system, and remove it entirely from the App to manage its lifecycle, ensuring predictable data synchronization across frames.