0 votes

I looked online for help with this problem. I saw a solution, which was using the connect() line, and I used it when I spawned the child - Tower1.connect("death", getparent(), subtractunits1()) and subtract_units1() is a function I created previously. It says "Invalid type in function 'connect' in base 'Node2D (Node2D.gd)'. Cannot convert argument 3 from Nil to String." Could someone help me?

in Engine by (124 points)

Ok, so I solved it, but a new problem has arrived. I changed the line to

Tower1.connect("death", get_parent(), "subtract_units1")

Now the program isn't crashing, but the function doesn't do its job. Could someone help me?

1 Answer

0 votes
Tower's Grandparent
--Tower's Parent

I'm assuming you are calling connect() from the Tower's Parent, which means get_parent() returns the parent of the tower's parent, i.e. the tower's grandparent. Does the tower's grandparent have the subtract_units1 function?

As an aside, are there any error messages in the debugger? That's what tends to happen when there's a signal connection mishap.

by (629 points)

I... I just realized... that... I should... have used... self

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.