Problem connecting signal to function using C# in Godot4

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

Hi,

I am trying to connect a signal of a InputEvent to a function in my C# code:

inst.GetNode<Area2D>("Area2D").InputEvent += tileclicked;

public void tileclicked(Viewport viewport, InputEvent @event, int shapeIdx)
{
    GD.Print("Test");
}

inst is a Node2D to which is attached a Area2D.When building I get the following warning:

No overload for 'tileclicked' matches delegate CollisionObject2D.InputEventEventHandler'

How do I proceed to connect the signal to a function and get all of the parameters ?

Thanks

:bust_in_silhouette: Reply From: Placeholder

Not sure if you’ve sorted this or not but for anyone who has this problem too like I did then the shapeIdx parameter needs to be long, not int.

The delegate is defined like this: public delegate void InputEventEventHandler(Node viewport, InputEvent @event, long shapeIdx);

1 Like