Closed AstrooLabe closed 6 months ago
The syntax is correct, this -for example- works for Godot 4.1.1:
using Godot;
using System;
public partial class Node2D : Godot.Node2D
{
public override void _Ready()
{
var button = GetNode<Button>("Button");
button.Pressed += OnButtonPressed;
}
private void OnButtonPressed()
{
GD.Print("Pressed");
}
}
What you used is the less idiomatic syntax- I wonder if the tutorial doesn't make clear enough to use a delegate and have a concrete ending name for the signal at Jumping and squashing monsters.
Can you show your code declaring the signal? Maybe it is something else, but having the full code will help.
I've followed the syntax in the documentation and the signal appears correctly in the node inspector. In a similar fashion, using SignalName.Hit
instead of "Hit"
inside the Emit method raise an error in VS Code but at least it doesn't block the build.
In a similar fashion, using
SignalName.Hit
instead of"Hit"
inside the Emit method raise an error in VS Code but at least it doesn't block the build.
The error in VSCode is due to the new versions of ms-dotnettools.csharp
not working properly when using Roslyn. You need to revert to Omnisharp.
The error in VSCode is due to the new versions of
ms-dotnettools.csharp
not working properly when using Roslyn. You need to revert to Omnisharp.
Thanks a lot, it indeed fixed this issue, but also the error with the signal connection as specified in the documentation! Since it's not something specified in the details of the C# for Godot extension, it would make a nice addition.
We probably need to be more clear about the C# for Godot extension not being needed (or even useful in any amount) with Godot 4.
Closing this issue as references to the C# tools for Godot VSCode extension were removed by #8826.
Your Godot version: 4.1.1
Issue description: The 3D tutorial tasks us to connect the OnMobSquashed() method to the Squashed signal by directly calling mob.Squashed (the global doc for signals display a similar solution) but Godot throws an error when I try to build the project with this solution.
Had to replace the line
mob.Squashed += GetNode<ScoreLabel>("UserInterface/ScoreLabel").OnMobSquashed;
by the linemob.Connect("Squashed", new Callable(GetNode<ScoreLabel>("UserInterface/ScoreLabel"), "OnMobSquashed"));
to make it works.URL to the documentation page: https://docs.godotengine.org/en/stable/getting_started/first_3d_game/08.score_and_replay.html https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_signals.html