#I have a problem with signals

1 messages · Page 1 of 1 (latest)

south wren
#

First of all I would prefer going into a call, it would be a lot easier for me to explain and a lot quicker, but here is my problem (I am curently in tech Support 1 VC):

I have a Signal "raycast_collided(collision_obj : Object)" that is in the script connected to the node "player_immobile_first_person". It is emited whenever the raycast which is a child of the node hits an object.

this signal is connected to 2 function, there is 1 which is in the same script as the signal, and it runs whenever the signal is emitted perfectly fine, then there is the other function which is in another script connected to another node that doesn't run and I don't understand why.

I tried running get_connections() and it doesn't find the function in the other script, even though Godot shows it is connected to the Signal as shown in the picture. PLEASE HELP!

PS: I have tried making a dummy script connected to a child of "player_immobile_first_person" with a function connected to a signal and it works, but when I tried another dummy script connected to a node that is a sibling to "player_immobile_first_person" it doesn't

here are some code snippets if that helps:

In "player_immobile_first_person" script:

signal raycast_collided(collision_obj : Object)

# more code between

func _process(delta):

if raycast.is_colliding():
var collision_obj = raycast.get_collider().get_name()
raycast_collided.emit(collision_obj)
# more code between

func _on_raycast_collided(collision_obj):
print(collision_obj)

#this succesfully prints the collision_obj

In the other node script:

# some code here

func _on_player_raycast_collided(collision_obj):

print("works")
#this does not print anything

royal blade
#

There's no image here, but there's also no code doing connections, meaning that your connections are done trough the Scenes using the "Signals" tab.

You'd have to show a screenshot of them.

south wren
#

my bad, here is a screenshot.

#

the "Head" and "Floor" nodes are the dummies for troubleshooting. Head is the child of the player object and floor is the sibling

royal blade
#

Both of the first 2 signals are connected to "_on_player_immobile..." but the function starts with "_on_player_raycast..."

Disconnect them trough the right click menu and re-do them.

south wren
#

there is still only "Head" that works (the child), the full name of the function is "_on_player_immobile_first_person_raycast_collided" btw

royal blade
south wren
#

the code I showed is from the "player_immobile_first_person", and the function in that script works well, it's the other scripts that don't work
(btw I renamed the function when I was connecting it to the signal so that it was "_on_player_raycast_collided" instead of "_on_player_immobile_first_person_raycast_collided")

#

I'll show you the code so that it's all clear

#

the code from "Interactible object":

extends Area3D

func _physics_process(_delta):
pass

func _on_player_immobile_first_person_raycast_collided(collision_obj):
print("works")

#

and there is the little button logo so I'm pretty sure it's connected

royal blade
#

So, to make sure i get this right.
You are expecting it so when the raycast touches anything, you get a total of 3 prints of "works"?

south wren
#

for now yes

#

but I am only getting 1 print of "works", the one printed by the node "head" (the child of the player node)

royal blade
#

The issue is def. the connection.
Unless you see some non-fatal error in the Debugger about it. I can only recommend disconnecting them and redoing them again, but i imagine you tried that already.

Try placing a breakpoint on each "print("works")" to know WHICH one exactly is working.

#

Remember to use F12 to "continue" after a breakpoint triggers.

south wren
#

I'm sorry could you tell me how to add breakpoints I'm not sure how

#

nevermind I watched a tutorial I'll try that

#

this is what I get, whenever I press F12 it instantly closes the game again, probably because the raycast gets called every frame so the breakpoint in "head" gets hit every frame, but the message from the screenshot stays the same

royal blade
#

The game shouldn't be crashing outside of some magic with threads or a fatal error. So that's kinda worrying.

At least we know that Head.gd is the one getting called. It all just keeps pointing to the Scene connections being wonky.

I can only recommend doing the connections trough code.