[SOLVED] Make objects clickable in a ES

I want to make my items clickable. I know how to make spatials clickabel. How can I get the entity in ES based game? My first thought here was to store the entityid as a userdata in the spatial. as soon as I click it I can get the entity id from spatials userdata if exist and add a new entity with IsClicked component and a Decay component to shortly highlight it with a Highlighting system.

So why ask when I have the solution? Because there is a downside as I have clickable and non clickable spatials but all as entities with position model and so on. I would need to store the the entity in my visual appstate and not for all of them only a subset (items only). So I would end with a maybe two visual systems one for items one for the rest. Or I would have to get the Item component in visuals with ed.getComponent(e, Item.class). Or do think to far and this the way going. Is there a better solution?

There is something else that makes these entities clickable other than some “Clickable” component. After all, if you think of such a system that uses it… what it’s going to do with that click?

And storing an entity ID in setUserData() is fine. I do it all the time. My “system that handles the clicks” is usually more specific to the function than that, though.

Mainly I want to pickup and place items. Click it should show a nice effect. I as well want a hover effect so the player knows that is clickabel. Seems I’m not on a completely wrong path then.

What bothers me is that my visual system display everything with a model, position and rotation. So I have one system to display everything. Now I have query Item.class to know if it is clickable on addEntities. But that Item component is not in the systems entity set, because for displaying it is a) not needed b) would be then only a subset of the visuals. I hope it is understandable what I mean

Oh well stupid me I can store for all spatials the entity id! But my clickab system only deals with item. Sorry bothering. Thanks for rubber duck debugging :wink: