Interaction between entities. #248
Unanswered
Chris-Mingay
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First off thanks for your really clear and detailed documentation, it's really appreciated! I'm just messing around with Arch to see if it's what I need / want and I'm wondering, is there a proper way to have related entities interact with each other? For example.
I have an Owner:
world.Create(new Owner(), new Position(0,0))
I also have a Pet:
world.Create(new Pet(), new Position(10,10))
Somehow I would like to dictate that the Pet belongs to the owner. In a non ECS solution I'd probably just have:
I would also like to check the distance between the Owner and it's Pet and if it's over 100, move the Owner towards the Pet. Again in a non ECS solution I'd probably just do:
I would also like to draw a line between the Owner and the Pet, I'd probably have this as part of the Owners Draw() method and let the Pet handle it's own Draw() method too.
Am I right in thinking in order to check the distance between the Owner and the Pet I need to store a reference to the Pet entity in the Owner class and then query Arch to get the Pets position and then compare to the Owners position (which I guess I'd also get from a query)? I see there is a Relationship system in the Extended lib (thank you again), but it's the extraction part I'm still unsure about.
Thanks again
Chris
Beta Was this translation helpful? Give feedback.
All reactions