Emit Signal wont work

Hello i face a realy wired problem. I try to emit an signal when my player is shoting

public override void _Process(double delta)
{
    base._Process(delta);

    if(_enabled)
    {
        RotateCamera((float)delta);
    }

    var viewmodelNode = _viewmodel.GetNode<Node3D>("weapon_1");
    if (viewmodelNode != null)
    {
        var weaponScript = viewmodelNode as WeaponScript;
        var animationPlayer = viewmodelNode.GetNode<AnimationPlayer>("AnimationPlayer");

        if (Input.IsActionPressed("attack") && _enabled)
        {
            if(_lockAnimation == false && weaponScript.CanShoot())
            {
                EmitSignal("PerformShotEventHandler");
                weaponScript.PerformShot(GetViewport().GetCamera3D());
                State = CharacterState.Attacking;
            }                
        }

        if (Input.IsActionJustPressed("reload") && _enabled)
        {
            weaponScript.StartReload();
            State = CharacterState.Reloading;
        }

        switch (State)
        {
            case CharacterState.Idle:
                this.PlayAnimation(animationPlayer, weaponScript.AnimationIdle, weaponScript.AnimationIdleSpeed);
                break;
            case CharacterState.Walking:
                this.PlayAnimation(animationPlayer, weaponScript.AnimationWalk, weaponScript.AnimationWalkSpeed);
                break;
            case CharacterState.Running:
                this.PlayAnimation(animationPlayer, weaponScript.AnimationRun, weaponScript.AnimationRunSpeed);
                break;
            case CharacterState.Inspecting:
                this.PlayAnimation(animationPlayer, weaponScript.AnimationInspect, weaponScript.AnimationInspectSpeed);
                break;
            case CharacterState.Attacking:
                this.PlayAnimation(animationPlayer, weaponScript.AnimationAttack, weaponScript.AnimationAttackSpeed, true);
                break;
            case CharacterState.Reloading:
                this.PlayAnimation(animationPlayer, weaponScript.AnimationReload, weaponScript.AnimationReloadSpeed, true);
                break;
            default:
                this.PlayAnimation(animationPlayer, weaponScript.AnimationIdle, weaponScript.AnimationIdleSpeed);
                break;
        }

        var camera = _head.GetNode<Camera3D>("Camera3D");
        if(camera != null)
        {
            this.HandleInteraction(camera);
        }
    }
}

But however i recive this error message

E 0:00:05:801   NativeCalls.cs:7404 @ int Godot.NativeCalls.godot_icall_2_838(nint, nint, Godot.NativeInterop.godot_string_name, System.ReadOnlySpan`1[Godot.Variant], Godot.NativeInterop.godot_string_name): Can't emit non-existing signal "PerformShotEventHandler".

But the signal exist i even connected it in the editor.

Ok i found the issue, i need to use the signal name without EventHandler

Instead of using a string to specify the name you can use the generated SignalName:

EmitSignal(SignalName.PerformShot);

Or you can use the generated EmitSignal{SignalName} function. This also give you type-safety for expected parameters:

EmitSignalPerformShot();
1 Like

Thanks :slight_smile: works perfect