Skip to content

autoRemoveTarget auto-removes the source? #169

@timsdsdio

Description

@timsdsdio

Perhaps I'm confused on the naming here but it feels like the only way to interpret this property in a way that lines up with what it does is to read it as "this is an auto-remove target" rather than "this will auto-remove the target". Could someone help me to understand how to properly interpret this?

To use the example from the docs:

const ChildOf = relation({ autoRemoveTarget: true })

const parent = world.spawn()
const child = world.spawn(ChildOf(parent))
const grandchild = world.spawn(ChildOf(child))

parent.destroy()

world.has(child) // False, the child and grandchild are destroyed too

In this situation, the target of ChildOf(parent) is parent, correct? But creating that relationship doesn't result in parent being automatically destroyed when child is (it's the opposite).

Am I mixing up what "target" means in this context?
Thanks for the help.

p.s. Seems every library I use by pmndrs is excellent. Kudos on the great work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions