Debug error : what it depends on ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jospic
:warning: Old Version Published before Godot 3 was released.

This follow statement causes dbg error as shown in the figure:

get_node("Parts").add_child(p)

I can not understand the reason for the failure , which still does not interrupt the normal execution of the project .
Anyone have any suggestions ?
Thanks in advance
-j

:bust_in_silhouette: Reply From: The_Duskitty

I think it’s because you’re using the function wrong as seen in documentation

void 	add_child ( Node node, bool legible_unique_name=false )  

And having looked through your game code

Having the “j” or “p” being the (node).new Doesnt work with that, it would appear that to properly use add_child you would need to do something along the lines of

Example

get_node("Test").add_child(Node2d) 

Or something along those lines, i believe that’s the reason why the hookups arent working as well

I dont know an alternative fix other than just setting all the joints manually in the editor for now until you find an alternative method of doing this properly

:bust_in_silhouette: Reply From: jospic

@The_Duskitty

Thank you for your answer. Indeed there is a mistake in my code because the statement

var j = PinJoint2D.new()

is wrong . The joint already exists because is instantiated by the object “Part”.

The statement above should be replaced by:

var j = get_node("parts/part "+str(i)+"/jointPart")

However I can not explain the errors of the debugger because the use of the command

add_child

seems correct .