0 votes


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! :D

Godot version 3.5.1.stable
in Engine by (57 points)

1 Answer

+1 vote

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.

by (8,099 points)

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! :D

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.