The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+3 votes

Hi, i'm using VideoPlayer to make a looping bg based on a video. Natively the video player does not have to option to loop, the answer in this forum is to track progress and just send "play()" again, but that makes a flicker in black while the stream is reloaded and i wouldn't want that on my bg.

I tried to come up with a node of my own to handle this issue, what i need to do is to create a new instance of video player underneath the one currently playing and then after a second, swap the nodes, the player that finished moved to the back to reload the video and the one on the back to the front.

I've had lots of issues trying to remove a node from a parent and adding it to another one, mora when the node is a stream player actively playing. Also there is no callback for "playing_finished" which could be very useful.

Anyways, what i need is a way of instantiating a node in a container, and then swapping it with another node in another container every certain amount of seconds (already got the timer structure, just having issues with the reparenting at runtime part).

Thanks in advance! =).

in Engine by (30 points)

2 Answers

+10 votes

Here's a solution encapsulated in a function:

func reparent(child: Node, new_parent: Node):
    var old_parent = child.get_parent()
by (332 points)
Error after reparent node
+1 vote

Nodes have a reparent method now:

by (18 points)
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 Frequently asked questions and 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 [email protected] with your username.