Solved - Change a text value for a specific pinned text object?

0 favourites
  • 6 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • I have a tower defense game where you are trying to stop robots. There are different robot enemy/object types and they are al contained in a Family called "Robots".

    When I spawn an object from Robots, I also:

    - Spawn a text object called "RobotsHealth"

    - Pin "RobotsHealth" to Robots

    - Set Text of "RobotsHealth" to the current health of that robot.

    So, far so good, this works perfectly (the starting health values move with the robots).

    However, when bullets hit "Robots", I want to update the value of "RobotsHealth" and I have this code:

    - Bullet1 On collision with "Robots" -> RobotsHealth | Set text to Robots.Health

    But this is changing the value for EVERY instance of "RobotsHealth".

    How do I change just the value for instance of "RobotsHealth" that is pinned to the "Robots" that was hit?

  • Two simple and easy methods:

    METHOD 1:

    METHOD 2:

    Which of the two methods to use? Any of them. A matter of taste, I guess.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Pin behavior also has PinnedUID expression. But it's much easier to use the hierarchy.

  • Two simple and easy methods:

    METHOD 1:

    METHOD 2:

    Which of the two methods to use? Any of them. A matter of taste, I guess.

    You are amazing!

    Thanks for giving me options - I tried them both.

    I hadn't used hierarchies before and that seemed like the more elegant solution, so I settled on that one and it works perfectly!

    Just one curious question: When you first spawn "RobotsHealth" there is a toggle option for "Create hierarchy". I didn't click it, because I see you didn't click it, but what does it do?

  • Just one curious question: When you first spawn "RobotsHealth" there is a toggle option for "Create hierarchy". I didn't click it, because I see you didn't click it, but what does it do?

    You can prepare the entire hierarchy (in the editor), say, a robot + two arms + two legs + head + health text. Then in runtime when you create this robot and tick "create hierarchy", it will be created with all those parts!

  • > Just one curious question: When you first spawn "RobotsHealth" there is a toggle option for "Create hierarchy". I didn't click it, because I see you didn't click it, but what does it do?

    You can prepare the entire hierarchy (in the editor), say, a robot + two arms + two legs + head + health text. Then in runtime when you create this robot and tick "create hierarchy", it will be created with all those parts!

    That is very cool!

    I've only been working in C3 for a few months now, I'm having a great time and constantly learning new tricks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)