Reparenting Objects/Triggering Interactions

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tboskk

Hi there!

I am working on implementing a Zipline System in Godot VR utilizing the Path and PathFollow nodes.

My plan was based of another users suggestion in 2D, to utilize a Path3D Node to create the Zipline path, with a Path Follow node to allow transition down the zipline on said path.

In order to allow this, I wish to set up a Area3D in the “interaction zone” of the zipline boarding station, for the player to “walk into” and press the ‘A’ button to trigger actual boarding of the zipline.

I’d assume to accomplish this, I would be required to have the Area3D trigger a signal to the PathFollow node upon collision with the Player, and the ‘A’ button being pressed.

From there, the Player AR/VR Node would need to be re-parented to belong to the PathFollow node, so that upon executing a modification to the Path Offset, I could effectively sling the player down the path, re-creating a zipline effect. (I imagine there is probably more to that, but I need to get there first heh.)

My issue is in being new to Godot, and GDScript in itself. – I’m not sure if this for:
One, sounds to be an effective method of accomplishing my goal; and
Two, how to actually go about Re-Parenting a Player Node from the root of the Spatial Node, into this PathFollow node specifically – let alone reverse that back afterwards at the end of said path.

And I wanna be sure there isn’t potentially a better way to go about the Interaction allowing the boarding of said Zipline, given that was just a rough idea of triggering the interaction?

I appreciate any help in advanced, thank you!

:bust_in_silhouette: Reply From: DaddyMonster

One Many ways to skin that cat. Given that it’s VR you could of course just teleport with an area and a button press as you suggest (perfectly valid approach), but I’d always recommend physical interaction with the environment in VR over button pressing. I assume you’re using Bastiaan Olij’s hands with the addon? If memory serves I believe they hold a reference to the object the hands are grabbing, so the code is pretty much there for you just to allow the player to grab the zipline grabby thing and to whizz off when both hands are on it. Up to you of course but I’d say that’s the more engaging experience.

Here’s a related tutorial.

Two Reparenting is easy-peasy:

parent ---> script
--- child_one
--- child_two

var c1 = $child_one
remove_child(c1)
$child_two.add_child(c1)