Custom Signal C#. Godot 3.5

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

It was necessary to add the word “void” after the “delegate


I am doing a lesson that is written in GDScript, trying to translate the code into C#.

time 15:38
But I am getting Build error

using Godot;
using System;

public class Player : Area2D
    float health = 10;

    [Signal] public delegate healthChanged(float newHealth);

    void TakeDamage(float amount)
        health -= amount;
        if (health < 0)
            health = 0;


        EmitSignal("healthChanged", health);

    private void _on_area_entered(Area2D area)

Failed to build project solution
error CS1001: Identifier expected [/Volumes/Data/Godot/LEARN Signals/LEARN Signals.csproj]

And in Visual Studio this line is highlighted (underlined the word “healthChanged”):

public delegate healthChanged(float newHealth);

The type ‘Player’ already contains a definition for ‘’ [Using signals, LEARN Signals]csharp(CS0102)
The type or namespace name ‘healthChanged’ could not be found (are you missing a using directive or an assembly reference?) [Using signals, LEARN Signals]csharp(CS0246)

You may wanna add the solution as answer? :slight_smile:

juppi | 2022-09-03 11:45

:bust_in_silhouette: Reply From: slavi

It was necessary to add the word “void” after the “delegate”

[Signal] public delegate void healthChanged(float newHealth);