Hi,
I’m new here so apologies if this question is basic, but it’s driving me a bit mad and I can’t find an answer on the forum.
What I’m trying to do
I’m creating an educational platformer for children aged 4 to 6. It’s a maths game where you have to collect even numbered coins but avoid the odd number coins.
If you collide with an even number the coin disappears and you get a point. If you collide with an odd number coin the character dies (goes back to the last checkpoint) and the coin disappears. If you jump on the odd number coin the coin disappears and you get a point.
-My issue
I uploaded two images: ‘Coin_even’ and ‘Coin_odd’ and I’ve set it up so that if you
collide with coin_even player gets a point and coin disappears.
collide with coin_odd player dies and coin disappears
Jump on coin_odd player gets a point and coin disappears.
I’ve attached some screenshots showing this.
However, I’m unsure of how best to incorporate the text (numbers) onto the coins.
Ideally I don’t want to have to upload an image for each individual coin with text embedded on the image.
I thought I could just duplicate the ‘Coin_even’ object multiple times on the scene and then just add text over the top of each coin. Obviously, when I do this the coin disappears but the text doesn’t. I need the text to disappear along with the coin.
Is there an easy way to group the text with the individual coin? I’m looking for the most efficient way to achieve this result. I’m hoping there’s a way to do it without having to have a condition and action for each individual odd number coin and each individual even number coin.
-Summary
I need a way to attach text (numbers) to coins in a platformer game so that when a coin disappears, its corresponding number disappears too. Ideally I want to avoid manually setting up conditions for each coin.
This is for linking health bars to enemies
But in your case you just link text instead
And you would get what you want
Last event where i check if HP is less than 0
Is where you check HOWEVER coin should be deleted
For example player in collision with coin
Where linking is made dynamically
For each object Enemy for me Coin for you
Which is not linked to Text you create Text
That is how you exclude them from getting multiple copies of objects to attach
Hi,
Thank you for taking the time to respond to me I really do appreciate it. However, I’ve spent a lot of time trying too unpack what you said and I really can’t make sense of it. I’ve just started using Gdevelop so this is entirely my fault.
What I’m Trying to Achieve:
Use a single coin image (called Coin_even) for all even-numbered coins.
Duplicate this coin multiple times in the scene, assigning each instance a unique variable value (e.g., 2, 4, 6, 8, 10, etc.).
Create one text object (CoinText_New) that dynamically displays the variable value of each Coin_even instance.
Link each CoinText_New object to its corresponding Coin_even instance so that:
The number appears above the coin.
The text updates dynamically based on the value variable of Coin_even.
When the player collects a coin, both the Coin_even and its linked CoinText_New disappear together.
This approach should let me avoid manually creating separate events for each coin while still allowing for unique values.
What’s Working:
CoinText_New instances are being created at the correct positions.
CoinText_New appears in the debugger and correctly stores the expected variable values.
The text updates correctly in the debugger when I check its variable.
If I manually set a text value (e.g., “HELLO”) in the Initial Text to Display field in CoinText_New, it appears correctly over the coin in the game and disappears when the coin is collected.
What’s NOT Working:
If I remove “HELLO” from the Initial Text to Display field and leave it blank, nothing appears over the coins in the game.
CoinText_New is not displaying the value of its linked Coin_even instance, even though the debugger shows that the text variable is updating correctly.
What I Need Help With:
Am I missing something fundamental about how text objects work in GDevelop?
How can I make CoinText_New display the correct value dynamically above each Coin_even instance?
Is there a better way to approach this problem?
I’ve attached a screenshot of my current setup. Any step-by-step guidance would be greatly appreciated since I’m still learning.
I am not even reading what you wrote
Your events does not look like mine
I don’t see anywhere in mine using at beginning of the scene
Where you also are missing some events
1st duplicate what you see then check does it work and come back here when it does not
Hi, Thanks again for your help, I appreciate it. I’ve followed your screenshot this time(see attachment). Could you check that it looks right as it’s possible I’ve made a mistake somewhere because it’s not really working. The coins (Coin_even) are no longer appearing on the scene at all. I’ve placed two of them on the scene but they are now not appearing in the game when I preview it.
“I am not even reading what you wrote”
I appreciate that you don’t want read my message but can I just check something so we’re on the same wavelength. I don’t just want to link the text to the coin so that it disappears. I want a way of being able to easily change the value of the text on each individual coin without having to have an event for each coin. So I thought maybe I could get it so that the text changes according to the variable value of the coin object (Coin_even) that it’s linked to?
Thanks again.
It was not like i am not reading your message because F U
It was like you did not replicate what you were shown
So i have hard time understanding why you even wonder it is not working
So reading your message would not change anything here
This time
1 - here should go your text action unless you have same exact text for each coin
2 - you do not have any condition to check when to delete your objects (so you are automatically deleting them on creation)
For example player is in collision with coin
To what you want to change text of each coin?
And to go ahead of your next question
IF objects are linked then text can take value from variable of your coin
So if you have some variable on your coins like ID or HP or Number (name does not matter it only matters that there is some variable) and each coin have different one then each text will display text according to coin to which it is linked to
But you need to do what i mentioned in #1 and you need to have that variable there on coin
Thanks for your help with this.
I take your point about the absence of a condition, I have now added this (Player is in collision with coin_even). I can now see the coins, but there’s no text on top of them.
I am a bit confused about what exactly you mean in point 1:
“Here should go your text action unless you have same exact text for each coin”.
What do you mean by “your text action”. What text action should I put?
Do i need to add something like the attached screenshot?
Do not show parts of what you did like right now you cut out part of it
Cause you do not know what is important and what is not
BTW whatever you just did is wrong
You are changing variable of text
That should be changing text value of text to variable of coins
In human language
Text object is there just to display something like price tag
You do not put price of price tag onto price tag
But price of item to it is attached to
This imagine you buy it for 1 dollar
You do not slap on it 1 dollar
You slap on it price of item to which it refers to like tomatoes potatoes chicken meat chips whatever
Look
You have some variable on your coins called value
So expression is correct Coin_even.value
Where is 1 you click add action
You click your CoinText_now object
1st action should be TEXT or something like that click it
And in value type ToString(Coin_even.value)