[SOLVED]
It was necessary to add the word "void" after the "delegate"
Hello,
I am doing a lesson that is written in GDScript, trying to translate the code into C#.
https://www.youtube.com/watch?v=NK_SYVO7lMA
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;
GetNode<AnimationPlayer>("AnimationPlayer").Play("take_damage");
EmitSignal("healthChanged", health);
}
private void _on_area_entered(Area2D area)
{
TakeDamage(2);
}
}
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)