-
Hi, I use koota in my new game, and I don't know how to remove relationship from entity. I want to use relationships to achieve the selected effect, like this: const player = world.spawn();
const item = world.spawn();
const Selected = relation({ exclusive: true });
// select item
player.add(Selected(item));
// deselect, bug entity cannot remove relationship
player.remove(Selected); Any help is appreciated, Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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 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. |
Beta Was this translation helpful? Give feedback.
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.
If you want to find out what the target entity is you can use
targetFor
.Although I do think it should be possible to remove all relations of a kind with a wildcard so I will consider adding that.