Skip to content

Adding component is async sometimes #186

@zepplondon

Description

@zepplondon

So I noticed that when you add a component to an entity that's already in the engine, it adds asynchronously. Which means that it's not retrievable immediately after adding. As I assume it becomes available only after next frame.
My case is: I need to modify a component. But before modifying it, I have to check if it's present in the entity or not. If not, then I'm going to add a new component of needed type and then modify it. But I can't do it, because after i call entity.add(), it's not present in the entity's components array. The problem becomes really bad when you have to call the modifying/checking function multiple times. Every time the "is component present check" returns null on a given entity. So I'd like to know if there's a workaround for this problem. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions