[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/jp/ - Otaku Culture

Search:


View post   

>> No.45443104 [View]
File: 38 KB, 690x372, export variable nodes.png [View same] [iqdb] [saucenao] [google]
45443104

>>45442121
>I think you must have renamed the CollisionShape2d to SwordCollision in the editor but forgotten to change it in the code.

Ahaha, I make that mistake all the time too. But I believe I commented those parts out because I switched over to using AnimationPlayer to handle attacks, so I probably messed up the animations. Thanks for looking out for me.

To reference other nodes in the hierarchy, the approach I typically take now is to make them export variables (use type hints if you're using GDScript) and assign them in the inspector. I recall this to be resistant against name changes, but I'm not 100% sure.

Also, with get_node, scene unique names (the % thing) let you write $%NodeName instead of $PathToNode/NodeName. It doesn't auto update on name changes, but it makes referencing nested child nodes very easy when you don't want to futz with assigning export variables through the editor.

Navigation
View posts[+24][+48][+96]