godotengine / godotengine/godot
Invalid NodePath when binding signal argument
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.2.2.stable.official [15073afe3]
### System information
macOS 12.6.7
### Issue description
When connecting a signal from editor's UI with binding NodePath argument, it has a relative path from sender, which becomes incorrect once received by other object.
This behavior makes NodePath binding useless in most of cases, because scripts are always attached to receiver.
### Steps to reproduce
1. Open any scene, attach script to it
2. Write simple function, supposed to receive signal with path to sender as argument, for example
```gdscript
func _on_receive_signal(signal_sender: NodePath):
var sender = get_node(signal_sender)
assert(sender == $Button)
```
3. Create any child node, for example `Button`, select it
4. Go to `Node` tab, right click on any signal, press `Connect...`
5. `Connect to Node` select root node, where script is attached
6. `Receiver Method` press `Pick`, disable `Compatible Methods Only`, select method from step 2
7. Enable `Advanced` switcher
8. `Add Extra Call Argument`, select `NodePath` from drop-down list, add it
9. Press `Assign...`, choose sender node, press `Connect`. Should be as on image below
10. Run project and trigger signal
Expected result:
`_on_receive_signal` gets path to sender node
Actual result:
`_on_receive_signal` gets `.`, impossible to get sender node, assertion triggered from example code
### Minimal reproduction project (MRP)
[SignalNodePath.zip](https://github.com/user-attachments/files/16420370/SignalNodePath.zip)
Contributor guide
Research direction
Start by opening the attached SignalNodePath.zip minimal reproduction project and reproducing the editor signal connection with an extra NodePath argument. Investigate the signal binding behavior shown in the reproduction; it is done when the receiver gets a usable path to the sender instead of `.` and the example assertion passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100