So I need to be able to tell whether or not an Entity is on another RigidBody. This is only for Entities in the PhysicsAppState.
To do this I’ve created a GroundCheckComponent simply hold a Boolean. This component is updated in the PhysicsAppState regularly. So now I can check whether or not a component is “grounded” by checking this component.
I’m using it in AppStates that require the entity to be on the ground. For example, in my CharacterActionAppState: the player should only be able to jump if he is grounded. However, to do this I need access to the PhysicsState to ray test. So it seems proper to add a component that the PhysicsState handles.
Also on A side note. Is it okay to just re-set the same component(versus creating a new one, like in the examples) to trigger a “change” in an entity
It’s a false optimization because all of the stuff going on under the covers is already making temporary garbage. Unless you are on Android then the generational GC makes these short-lived objects nearly free to GC. (And I guess Android is getting better.)