Interaction between dissimilar entities.

53 views
Skip to first unread message

That Guy

unread,
Nov 14, 2015, 3:25:13 AM11/14/15
to Ash Framework
So i have a car entity, and a obstacle entity.
The car needs to avoid hitting the obstacle, and the code for that will obviously be in a system (all logic goes in the systems).
But a system operates one a single specific type of node. And my car and obstacle entities do not have overlapping components to create a common node.
The car needs to have a velocity component, the obstacle does not. The car has a destination component, the obstacle does not.

So how will I have access in my system to both cars and obstacles, in order to do the required obstacle avoidance?
Or should I keep a separate list of obstacles in my System? ( and I'd have to ensure it is kept up to date when obstacles are created - destroyed).

Richard

unread,
Nov 14, 2015, 8:57:58 AM11/14/15
to Ash Framework
Hi

It's not a rule that systems can only operate on one type of node, it just works out that way most of the time (sorry if any of the documentation miss-led you on this). The rule is that systems request lists of entities from the engine based on their components (i.e. based on a node type). Your collisions system can request two lists, one of obstacles and the other of cars, and test for collisions between members of one list and members of the other.

See this collision system in the asteroids demo project which uses four different node types - https://github.com/richardlord/Asteroids/blob/master/src/no-dependencies/net/richardlord/asteroids/systems/CollisionSystem.as

Richard

That Guy

unread,
Nov 14, 2015, 12:16:59 PM11/14/15
to Ash Framework
Ah, ok. The one node type per System is just a design choice that crept in while making my version of Ash (using generics in C#), and then I just assumed that it's a principle of entity systems. Thank you very much for clearing that up for me.
Reply all
Reply to author
Forward
0 new messages