[SOLVED] Changing the Text of a Text Object to a Variable of the Group Object it's in Collision With

I know this might seem easy when reading the title, but I’ve run into some problems.
I want to make a card game and show the amount of cards a player has in a collection tab, I’m starting out by creating a text object in an area in each card.
I’m having trouble on how to change the text to the variable of the card it’s in collision with.


This is what’s happening.
It’s using the variable of the emerald card (the last one) for ALL cards.
And if they were all actually 117, the ones on the left would have their picture appear.
Here’s what I have:
image
I know it’s simple, but I couldn’t think of conditions that wouldn’t break it or make it work only partially, like randomly picking.

Also, side quest, if you want to help me out further :star2:, I have these four conditions that show the card if you unlock them, but when you unlock two or more at once it completely breaks, again, a group problem, I’d assume.


Thanks in advance! (Hopefully.)

For the 1st question, you might need a for each object. Right now it’s picking all of the objects in collision but the actions don’t know which object goes with which so it uses I belive the object that was created the earliest.

Cards is on layer
For each cards
… Text is in collision with cards
… … The rest of your events

Another option would be to use linking.

IDK about the 2nd question.

1 Like

I think I’ll try linking! Thanks for your answer, I’ll let you know if it works.

1 Like

I tried again and this was the result I got, pretty weird.


The emerald from before became 1, but the stone didn’t.
I know they’re all linked properly, so what’s the problem?
Here are my events:
image
The only thing I missed was “For each cards,” but I’m not sure what that is.
Until a day ago I didn’t even know this existed:
image
So I wouldn’t be surprised if I missed something else.

Huzzah! Nevermind, I got it to work, here’s what I got:


I removed the linking and added this:
image
Like I said, I never knew that existed!

1 Like

I’m glad it’s working. As for the linking. You wouldn’t need to check both the link and the collision but you would need to use a for each object.

For each cards
…among text linked to cards

You would also need to create the link with a for each object as well. You could check the collision and link the objects. I like to add the object based on the other object. It works for me. Everyone has their own methods.

For each cards
… text is in collision with cards
… Link text and cards

Or

For each cards
… Add text object at cards.X(), cards.Y()
… Link text and cards

1 Like