Consider the following:
- does the widget really need to know the reference of the artefact actor? The widget’s job is to show the exciting UI bits - perhaps the widget should be told the distance to display and told how to behave rather than made look for actor refs and extract their data.
- instead of using the
Get All Actor of Class
node, you could instead try:
Perhaps there is no need to iterate over 1000 artefacts? Perhaps we can find just the ones that are close by and only sort those by distance? This is irrelevant if you have 10, very relevant if you have 10k. For this, the artefacts (or their placeholders) would need to have some form of collision.
- this widget:
Is not referenced (bar the the viewport holding onto it). If you ever call this script again, you will orphan the existing widget and create a brand new one. Again, this may be utterly irrelevant, may you only need to detect the artefacts once or something else makes this widget obsolete.