need clarifications on how to propely copy a node and parent

Ok i was using the copyTo method to copy a node and i need to parent it to the same thing it copied .

        self.copyShip = self.ship.copyTo(self.ship)

The copyship is supposed to be hidden until the player does a barrel roll. The ship then hides itself until the barrel roll is done. The original ship is properly rendered. But when the copyship is supposed to show it dosent. What am i doing wrong?

copyTo() has the same usage as instanceTo() which you can see in the manual

Basically you want to make self.copyShip into an empty node first before doing self.ship.copyTo(self.copyShip). What you have now just copies the ship node into the ship node.

self.copyShip  = parentNode.attachNewNode('barrel-roll-ship')
self.ship.copyTo(self.copyShip)

There’s one difference though, with copyTo you can do this:

self.copyShip = self.ship.copyTo(render) 

to avoid getting a new subnode every time you copy.

1 Like

Well i need to make a subnode only on the initializing method.