Having problems connecting signals to another object via the godot editor

Godot Version

4.3-Stable

Question

Hello. I am making a 3D game, but, I am struggling with connecting the signal I made to another object with the Godot editor. This code can also only connect to the player, which the signal is made in. Not sure if it’s a bug with Godot 4.3, or if I am just doing stuff wrong.I am not sure why, there is a warning the pops up, but I do not know what it means:

W 0:00:00:0699   The signal "sendSig" is declared but never explicitly used in the class.
  <GDScript Error>UNUSED_SIGNAL
  <GDScript Source>player_script.gd:17

If you need the player code, here is the code:

extends CharacterBody3D


var capMouse : bool = false
var isColliding : bool = false

@export var SPEED = 5.0
@export var JUMP_VELOCITY = 4.5

var look_direction: Vector2 

@onready var camera = $Camera3D
@onready var toolRayCast = $Camera3D/Tool/RayCast3D

var cam_sense = 50

signal sendSig

func _physics_process(delta: float) -> void:
	Movement()
	GravityAndJump(delta)
	InteractionCollision()
	PauseMouse()
	QUIT()
	
	RotateCamera(delta , 0.5)
	move_and_slide()
	
	#if (isColliding == true):
		#print("Yes")
	#elif (isColliding == false):
		#print("No")

func _input(event: InputEvent) -> void:
	if event is InputEventMouseMotion: 
		look_direction = event.relative * 0.01

func RotateCamera(delta: float , sense_mod : float):
	
	var input = Input.get_vector("ui_left" , "ui_right" , "ui_down" , "ui_up")
	
	look_direction += input
	rotation.y -= look_direction.x * cam_sense * delta
	
	camera.rotation.x = clamp(camera.rotation.x - look_direction.y * cam_sense * sense_mod * delta , -1.5 , 1.5)
	look_direction = Vector2.ZERO

func InteractionCollision():
	if (toolRayCast.is_colliding()):
		var collider = toolRayCast.get_collider()
				
		if (collider.name == "RepairObject"):
			isColliding = true
			if (Input.is_action_just_pressed("interact")):
				pass
		elif (!collider.name == "RepairObject"):
			pass
	else:
		isColliding = false

func Movement():
	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	var input_dir := Input.get_vector("left", "right", "up", "down")
	var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
	if direction:
		velocity.x = direction.x * SPEED
		velocity.z = direction.z * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)
		velocity.z = move_toward(velocity.z, 0, SPEED)
func GravityAndJump(delta):
	# Add the gravity.
	if not is_on_floor():
		velocity += get_gravity() * delta

	# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY
		
func PauseMouse():
	if (Input.is_action_just_pressed("pause")):
		capMouse = !capMouse
		
		if (capMouse == true):
			Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
		else:
			Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
			
func QUIT():
	if (Input.is_action_just_pressed("quit")):
		get_tree().quit()


func _on_ready() -> void:
	emit_signal("sendSig")

Help is gladly appreciated :slight_smile:

Hi, I dont understand exactly what is your problem. Are you able to connect the signal but it is not working? or you cant connect the signal at all?

Assuming it is the first option, to which element are you connecting?

HINT: take into account that nodes are loaded from child to parents, so if the node you are connecting to is higher in the hierarchy (its parent for example), it will not be loaded yet when the signal is emited, because you are emitting it in the _ready function. Therefore, the signal will not be received.

Thanks, I am going to try to explain as best as I can. So, I have this object called “repair_object” That when the signal is sent, from the “player” character, I want it to do a specific thing. The problem I am having, is that the signal can only connect to the player, and no other object. Hope that cleared something up.

EDIT: Specifically talking about connecting through the Godot interface

Ok, I more or less understand I think. So you will not be able to connect the signal outside the player character if it is not instantiated or added as a child on another node. For instance, if you add the player character scene to, let’s say, a World node, and also add the repair_object scene to the World node, then you should be able to connect signals.

Is this your situation?

By the way, I’m assuming that the script is attached to the root node of the character scene. Is this the case? Maybe an image of your node hierarchy would help

Sure!

This is the world hierarchy:
Screenshot 2024-09-05 222809

And this is the player hierarchy:
Screenshot 2024-09-05 222819

And if I understand correctly, the signal as to be sent from the world root instead of the player… I am not a native English speaker, so, maybe I misinterpreted that :expressionless:

EDIT: For some more context, the place I am sending the signal from is from the player, if that was what you were asking about

You can select your player instane in the world scene, and connect that signal to your RepairObject (also in the world scene) through the editor in the Node tab like any other signal.

I did indeed know that. The problem is that it doesn’t show up in any other object except the player.

What doesn’t show up?

The signal name. The ‘sendSig’ signal. I am really bad at explaining

Ah, that is correct and good, the signal only exists on the player; it is sent/connected to anything with a script.

You should select the player in the world scene, go to signals, doble-click on the signal, and in the window that pops up you should be able to see the repair_object. double click on it.

1 Like

Wow! That… Worked. Stupidly easy, and so sorry for the inconvenience :sweat_smile:

1 Like

ejjee nice. That is how connecting signals works. Then, you can also change the name of the method if you need it, but before pressing connect once selected the destination object

2 Likes

Thanks for being nice, and patient with someone like me. Who’s stupid