Zay-ES EntitySets in AppStates

Is it okay to have a AppState that handles multiple EntitySets?

For example: In my PhysicsAppState I use the PhysicsRigidBody tied to the entityId to update the Position component.

But say I want to move the RigidBody around. So I added a Velocity component. Would it be normal to have a EntitySet with (Position, CollisionShape) and a set with (Velocity, CollisionShape). Where I update the velocity set first

Depends who or what applies that velocity. If it is kind of an AI or input controller then you will have a separate state for this. I some times also have more than one set for example my invader example had two sets in the collision system.
So as you can see this depends highly on your use case.

Yeah I think it’s fine this way. However, is there a way to get an EntitySet of entities that have (Velocity, CollisionShape) but not watch for changes in CollisionShape? Does it matter?

Because I will have Velocity used on non physical entities as well. I don’t those showing up in my PhysicsAppState.

I’m not sure I understand, but a system only queries for components it is interested in. If you have other non physical entities with velocity you just add velocity and it will not show up in the physic system. I sometimes use tagging components which I only use for query the entity set.
Not sure if that was your question.

Yes I think. So is it okay to do:

velocitySet = ed.getEntities(VelocityComponent.class, CollisionShapeComponent.class);

Even though I only need VelocityComponent? Because if I don’t use CollisionShapeComponent is could pull in entities that are not physical. And CollisionShapeComponent will always mean it’s physical.

Ok yes makes sense so the collision shape component is in that case only a tag as you are not interested in the data and use it only to query the entities. I do this as well on occasion

Okay. Now say I wanted to applyImpulse( for example, a jump) to a rigidBody. Should I add a Jump component and a new EntitySet in my PhysicsAppState? But If I keep following this pattern I will have tons of EntitySets in PhysicsAppState.

Would it be correct to have a ImpulseComponent that holds a list. And in that list is a queue of impulses that should be applied to the corresponding RigidBody?

If you really have multiple impulses that can be applied to one entity then you have many entities attached to the one entity. So your Impulse component has an entity ID of what entity it applies to. And then you can make as many impulse holding entities as you want that point to the entity to really apply impulse to.

And yeah, my own physics system has several entity sets it manages.

So, let me know if I understand, I should have a Jump entity that has an ImpluseComponent with the player’s entityID? And the PhysicsAppState will look for changes in the Jump’s ImpulseComponent and then apply?

The physics state will watch for all entities with an ImulseComponent… and apply the impulse to whatever entity it is referencing every frame until the impulse component is removed from that entity.

Though personally I might do jumps and player control in a different way… it gets more complicated to explain.

I saw that BetterCharacterControl uses applyImpulse(). But I think just adding (0, 10, 0) to the linearVelocity vec3 in the VelocityComponent will do just fine?