Skip to content

How to remove relationship from entity? #132

Answered by krispya
wcp1231 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello! A relation always has a target, an entity that it is in a relationship with. So if you add a relation for a specific item, you need to remove it for that same item.

// Select item
player.add(Selected(item));

// Deselect item
player.remove(Selected(item))

If you want to find out what the target entity is you can use targetFor.

const item = entity.targetFor(Selected)

if (item) entity.remove(Selected(item))

Although I do think it should be possible to remove all relations of a kind with a wildcard so I will consider adding that.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@wcp1231
Comment options

@krispya
Comment options

Answer selected by wcp1231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants