Copying a Node Path

Hello. Is there a difference between

new = my_node.copy_to(render)

and

import copy
new = copy.deepcopy(my_node)
new.reparent_to(render)

?

No, there is not, other than that the first option is slightly more efficient.

In fact, NodePath’s deepcopy is implemented as my_node.copy_to(NodePath()), basically copying it into an empty scene graph.

Thanks for your clarification! :grinning:

Hello again.
I want to copy an Actor class using the copy.deepcopy function. However, it would return a regular NodePath and not an Actor. If I do not want to use actor.copy_to, is there any other solution?
(I know it sounds weird as I am not using the default functionality.)

The solution is not to copy an Actor using copy.deepcopy. It is not supported. If you wish it to be, please file a feature request.

Thanks for your response. I have decided to use actor.copy_actor