Skip to content
Discussion options

You must be logged in to vote

OnEnter(State) is a schedule that only gets executed once when you change states. That means you cannot wait by letting frames run until the resource is there.
Doing anything via commands means that the action is deferred until the system apply_deferred is called the next time. Bevy calls this system for you in some places which explains why waiting a frame works for systems that run every frame.

Your options:

  • Add the resource to the world directly in an exclusive system
  • Order your systems and manually add apply_deferred between them
  • Add the resource to the app in the very beginning via init_resource or insert_resource

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@badcodecat
Comment options

Answer selected by badcodecat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants