When an entity is created and added to the system, PhysicsBodyComponent.body will not be instantiated.
It only gets instantiated after a null check in PhysicsSystem::processBody(). This means that we would have to wait for 1 engine tick in order to be sure all physics objects are properly instantiated.
A fix would be to call PhysicsBodyLoader::createBody() from ComponentFactory::createPhysicsComponents(). At that point we have all the information we need to build the physicsbody if I am not mistaken.
SpineComponentFactory::createComponents(...)and CompositeComponentFactory::createComponents(...)both call
ComponentFactory::createCommonComponents(entity, vo, ...);
ComponentFactory::createPhysicsComponents(entity, vo)
practically creating the same object twice. In case we call PhysicsBodyLoader::createBody() from ComponentFactory::createPhysicsComponents() it even creates two bodies at the same spot.
Maybe also implementing float PhysicsBodyComponent.initialAngle and Vector2 PhysicsBodyComponent.initialPosition could make it easier to instantiate an object at the right position and rotation ?
When an entity is created and added to the system,
PhysicsBodyComponent.bodywill not be instantiated.It only gets instantiated after a null check in
PhysicsSystem::processBody(). This means that we would have to wait for 1 engine tick in order to be sure all physics objects are properly instantiated.A fix would be to call
PhysicsBodyLoader::createBody()fromComponentFactory::createPhysicsComponents(). At that point we have all the information we need to build the physicsbody if I am not mistaken.SpineComponentFactory::createComponents(...)andCompositeComponentFactory::createComponents(...)both callpractically creating the same object twice. In case we call
PhysicsBodyLoader::createBody()fromComponentFactory::createPhysicsComponents()it even creates two bodies at the same spot.Maybe also implementing float PhysicsBodyComponent.initialAngle and Vector2 PhysicsBodyComponent.initialPosition could make it easier to instantiate an object at the right position and rotation ?