• 2D
  • Changing a Child Node into the Parent

Is there any way for me to change this CanvasLayer child node into the parent? I am trying to make it so when you use the ink splotch, it will spawn where the player is, then stay there and go above all other layers using that CanvasLayer, with the sprite's x,y position staying intact. I want it so that the ink splat will spawn at the player's position, but the canvaslayer brings it in front of the player. How would I accomplish that?

Thanks for the help in advance.

You could maybe try this, though I’m not sure if it will work:

func change_parent(node, new_parent):
	var old_parent = node.get_parent()
	old_parent.remove_child(node)
	new_parent.add_child(node)

Though if you just want the sprite to be over the player and other objects, and all the objects are on a single-layer/no-canvas-layer, you may be better off adjusting the Z index of the sprite instead. Setting the Z index to not be relative to the parent (z_as_relative) and then setting the z_index to something really high should make it draw on top of everything with a lower Z index.

Thank you! Changing the canvas layer to the parent didn't work, as it just locked the position to the corner of the screen (and I was thinking it would do that since it is a CanvasLayer, but it was worth a shot haha), however changing the z_index worked perfectly for my game! The only small issue is that the instanced scene follows the player, or the parent that spawned it. I think it would it be ideal to make the instanced splat a sibling of the player instead of child of it, but I could be wrong.

Anyways, thanks for the help!

Awesome, I made it so that the new splat scene is a sibling to the character, and copied its position in the world, and it is looking FLAWLESS! Thanks so much for your help @TwistedTwigleg ! I just noticed that you are hitting 1,000 likes now, so I'll tell you thanks for everyone that you've helped over the years too! :) I really couldn't do any of this without the personalized help that I've gotten from you. And I think I speak for everyone there! Thanks so much, and have a good rest of your day!

@TheRealLSWC said: Awesome, I made it so that the new splat scene is a sibling to the character, and copied its position in the world, and it is looking FLAWLESS!

Awesome, I'm glad you were able to find a solution! :smiley:

Thanks so much for your help @TwistedTwigleg ! I just noticed that you are hitting 1,000 likes now, so I'll tell you thanks for everyone that you've helped over the years too! :) I really couldn't do any of this without the personalized help that I've gotten from you. And I think I speak for everyone there! Thanks so much, and have a good rest of your day!

Thank you! :heart: