+1 vote

So I'm making a tetris like game. I setup my scene like so:

--Ysort # meant to contain the pieces that the cart deposits
--Cart # transports the piece from top to bottom
  --Piece # the piece is just a block

So I want it so that when the cart reaches the bottom of the grid the piece it is transporting gets reparented to the Ysort. I know how to setup the movement, collisions, signals, and get them working. I just don't know how to move the Piece from the Cart to the Ysort. How do I do this?

in Engine by (127 points)

1 Answer

+1 vote
Best answer

Oh I figured it out. When the cart hits the bottom I had to:

  1. Store the piece in a variable.
  2. call the remove_child() fuction on the cart
  3. the add_child() on the Ysort

var piece = cart.get_node("piece")

Word to the wise: Let the parent re-parent nodes

by (127 points)
edited by
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.