So my current setup is a grid based movement system that relies on checking a pos against a storage to see if a tile exists. I would be checking this for multiple reasons and it would be used across many systems. My problem is how do I easily share a destination position across systems in the same frame. I’m currently using a rather large system that I do not like to handle multiple cases. What I want is to somehow create a resource/component once that will contain the players destination position and the systems will be able to do work based on where they move. I’ve tried creating a resource and made the system run first in the frame but the systems after will complain the resource does not exist. What am I missing to have access to a resource created in the frame of and how would i clean up the resource so stale input is not read more than once?
#Saving players destination for use across systems
5 messages · Page 1 of 1 (latest)
I believe adding resources happens at the end of each stage. Currently what I assume you're doing is adding the resource in the Update stage and then using it in systems also in the Update stage, since the resources isn't actually added to the world until the end of the stage, the systems can't access it. Try moving the system that adds the resource into the PreUpdate stage.
.add_system_to_stage(CoreStage::PreUpdate, your_system)
If there may or may not be a destination at any given time, you could make your resource Destination(Option<Vec2>) or whatever. Then you can just update the resource instead of inserting it, which would be instant.
what is a workaround for this in iyes loopless?
I'm not sure, I don't use it