[SOLVED] Linked objects not displaying properly

Heyo, I’m having difficulties with displaying objects. What I want to achieve is to display some objects when the player hovers their cursor over the enemy. Here is the code:

All the objects display perfectly if there’s only one enemy in the scene. It looks like this (I know it looks really, really rough but UI will come later :sweat_smile:):
image

However, it just stops displaying if I place more than one enemy in the scene. Here’s what it looks like (I am hovering over it, screenshotting just doesn’t include the cursor.)

I’ve tried finding related posts, I couldn’t find anything similar to my problem.
I’ve tried reversing the link order, it didn’t work.

Am I missing something or is there a different way to approach this? Thanks!

In the last event, it’s not picking the linked objects. I prefer to use the take into account as a condition. It’s my preference. It makes the code look lighter and easier for me to read.

This would be easier with the sticker behavior. I’ll modify my project to use it for you and for anyone who reads this in the future.

Here’s a simplified example that I made to test my logic and show my method. I’m not saying it’s the only or best way. While the sticker method is usually easier. I though it was important to discus the basics.

When you use loops like for each object, it’s usually more efficient to do the conditions first. Especially the first event. If the at the beginning is inside the for each object the loop is still going to be processed. It will continue to check if it’s the beginning for each object not just once. If there are 10 objects, it’s going to check if it’s at the beginning 10 times instead of 1.

Here is the same concept using the sticker behavior on the text objects. The sticker behavior has its own linking process. So, you can use the built-in link or it’s functions.

You can also set the objects to be destroyed then the main object is deleted.

Yes, I switched to stickers some time after I posted, it’s so much cleaner like you said :smiley:

I followed your concept code to a T, and it still doesn’t work with multiple enemies. Am I missing something?

I don’t see the is Stuck to conditions. It’s applying the actions to all of the text objects and the plane.

I was exactly looking into that as soon as you posted this. I tried to put those conditions into the normal event and then in the “for each object” event but none of them worked.

Quick update: I removed the hide actions and confirmed that the code now only updates the stickied objects. Is it something wrong with my “hide” actions?

The is stick conditions should be with in the for each object to pick the matching stuck objects as well as the last event to hide just the ones not being touched using another for each object with the stuck to condition

It’s finally working! Thank you so much!

If I understood correctly, it wasn’t showing properly last time since, while I was hovering on one enemy, I wasn’t hovering on the other. That’s why there was a contradiction.

It really feels great when you get on top of a problem and at the same time understand why it was happening :laughing:

Final code for whoever needs it :heart:

1 Like