use entity outside with(world) {...} block? #131
Replies: 3 comments
-
Where are you using that code? In general an entity is just an ID and does not know about its world or components. Therefore it needs to be used in the context of a world to lookup the data of that ID and hence the with(world) syntax. However if you are in a Fleks system then you don't need it because then you are already in the context of a world. In short: outside of a Fleks system you need with(world). Otherwise, you can skip it. |
Beta Was this translation helpful? Give feedback.
-
Ok. Thank you. Where am I using that code?
I do not know if it can be done better, but sometimes I prefer to use more smaller classes than one long class. |
Beta Was this translation helpful? Give feedback.
-
Makes sense. Sometimes you might not need a class and instead you can use extension functions for your world/system. That way you also don't need the with(world). |
Beta Was this translation helpful? Give feedback.
-
Hello, I just want to ask if I can use entity outside with(world) {...} block?
Now I write:
Can I do something like this?:
Beta Was this translation helpful? Give feedback.
All reactions