Is there a '$Label.get_font("font").make_unique()' method?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Redical


I’ve just finished making a local-multiplayer joining system for a 2D Platformer I’m making, and I want to make it so that the font’s outline colour matches the player’s colour.

I’ve succeeded in making the font colour different depending what player it is, but the problem I have is that the font changes the first player’s font to red, then the second player’s to blue, but then they’re both blue because the font is the same and the blue player was the last spawned in.

Here’s the code I’m currently using:

if colour == "blue":

    # Here would be the line of code that would be something like:

    # Change outline colour (fully functional, by the way)
    username.get("custom_fonts/font").outline_color = Color(0, 88, 255, 255)

    # Here is the code that changes the player's skin,
    but that's not really relevant

I know there’s a “Make Unique” button with fonts in the editor, but this time I have to do it through code (GDScript, just to be clear xD).

If you know another way that I can do
this code in the first place, then I’d love to hear it.
Also, I can give more code and settings if you need it.
Thanks for any help! :smiley:

:bust_in_silhouette: Reply From: Inces

Every Resource needs to be created with duplicate()to be considered unique. Editors option to make_unique and local_to_scene do it under the hood.

Thank you!

I tried what you said, and what you said is definitely the correct solution,
but I discovered the problem I had wasn’t that the font needed to be unique,
it was just that because the font was created through code, the font outline size was set to zero!

So basically, all I had to do was write this with the code that made the font:

username_font.outline_size = 1

It is a bit pathetic that that was all I had to do to fix it, but oh well, that’s just game development for you. xD

Thank you for the help! :smiley:

Redical | 2023-01-11 04:40