#Any way of unbinding arguments in a signal?

13 messages · Page 1 of 1 (latest)

grave wigeon
#

I've got this signal here.

This just takes up a lot of screen space and was wondering if there was a way to reduce the number of arguments. Everything with an _ is something I'm not using.

I would most prefer to just tell Godot to not send those extra bits all together but I haven't been able to find a way to do this. I need to be able to do it through code as well.

I appreciate any help, I haven't been able to find anything to help from documentation or googling.

shadow plover
#

It's hard to tell with just your function definition, but can you pull any of the other data from the Node2D or from the body_rid?

grave wigeon
# shadow plover It's hard to tell with just your function definition, but can you pull any of th...

Not sure what you mean by other data. I'm us the body to identify what tilemap has been collided with (I have multiple tile maps) and I'm using the body_rid to identify the specific cell.

I'm getting this from body_shape_entered signal from an Area2D. Which returns RID body_rid, Node2D body, int body_shape_index, int local_shape_index

I want to know if I can make the body_shape_entered signal not emit the extra arguments I'm not using.

zinc cloud
#

have you tried unbind(args_count) yet?

grave wigeon
#

It seems unbind doesn't work with signals

#

Invalid call. Nonexistent function 'unbind' in base 'Signal'.

zinc cloud
#

You need to use it with the callable, not the signal. It should work with built in signals as far as I am aware, I remember using this a couple of times in my project.
body_shape_entered.connect(_on_body_shape_entered.unbind(4)) should connect the signal with no passed arguments

#

if you only want the first two parameters, body_shape_entered.connect(_on_body_shape_entered.unbind(2)) should work.

#

Make sure _on_body_shape_entered only expects the first 2 parameters, remove the others or it won't connect correctly and give you an error

grave wigeon
#

I probably should've realized this sooner considering I've used bind before lol

#

Also seems that I can use bind and unbind together, that's pretty handy.