![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | julkip |
I am trying to work with custom signals. My code looks somewhat like this (abbreviated):
Bullet.gd
extends KinematicBody2D
signal hit_walln
func _process(delta):
var collision = move_and_collide(velocity * delta)
if collision.collider.name == 'WallN':
print("Now emitting hit_walln")
emit_signal("hit_walln")
Main.gd
func _on_hit_walln():
print("recieved hit_walln")
I have tried connecting the signal both using the UI and using
func _ready():
connect("hit_walln", get_node("Main"), "_on_hit_walln"
in Bullet.gd. Both Methods show the message “Now emitting hit_walln”, but only the method using the code shows the message “recieved hit_walln”. I am a bit stumped by this, because I have connected other (non custom) signals using the UI in the same project before (timeout() on Timers to be exact) and those work flawlessly.
Is there a difference between those I don’t see?
I get an error saying: “Non-static function emit_signal() can only be called from an instance.” My script is attached to a kinematicbody2d. I want to call emit in _process().
Stormwindy | 2019-06-18 14:21