Skip to content

PhysicsBodyComponent.body is null #83

@kschoos

Description

@kschoos

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions