#How to differentiate two kinds of entities with the same components?

1 messages · Page 1 of 1 (latest)

silent granite
#

I have an entity for my player and and entity for the enemy. Both of them have [PhysicsVelocity] and [Speed] as components. (Speed just stores a single float)
This 2 components are inside the PlayerMovementAspect.
Then i have the PlayerMovementSystem which iterates on the entities with the PlayerMovementAspect, takes keyboard input and change their velocity.

Of course, this moves both the player and the enemy.
How can I/should I differentiate both of them so I move only the player?

It feels like i'm having a problem with architecture other than with ECS code knowledge. Should i separate the Speed component into a PlayerSpeed and an EnemySpeed one? Should I incorporate the speed float inside other components that are exclusive to the player or the enemies? Am i missing something else?

I'm new to ECS and my knowledge basically comes from the 1.0 tutorial by CodeMonkey and i couldn't find whats the right solution anywhere, so sorry if it's a dumb question.

median talon
#

something like a Player tag would be a general approach

#

or if multiplayer you might need LocalPlayer as well to differentiate between other players and yourself

silent granite
#

the game is single player so just the Player tag does the job