0 votes

I don't know what went wrong.This problem has been bothering me for nearly 2 days.Is there a god who can help me?
When running the test "health" "set_health" "this.health" value becomes "5"

public class stats : Node
{            
    [Export]  private int Max_Health=8;
    public int health;
    public int set_health
    {   
        get { return health; }
        set
        {
            this.health=value;
            GD.Print(set_health);
            GD.Print(health);
            GD.Print(this.health);
            if (set_health<=0)
            {
            EmitSignal(nameof(nohealth));                       
            }   
        }    
    }
        public override void _Ready()
    {
        health=Max_Health;
        GD.Print(health);
    }  
    [Signal] delegate void nohealth();
}
Godot version 3.3.2
in Engine by (19 points)
edited by

1 Answer

0 votes
Best answer

Do you by chance have maxhealth value 5 in editor through export? In editor select stat node and check inspector for maxhealth value.

by (122 points)
selected by
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 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 webmaster@godotengine.org with your username.