Open svntax opened 1 month ago
Hey, I'm sorry. I didn't document this properly. I implemented some functions for casting. If your node is also a Node2D, changing the line to:
self.target_node = Node2D.cast(self.get_node(self.target_node_path))
should fix the issue. If you have any other problems, feel free to ask.
Thank you! That fixes the problem for me.
How do you work with references to other nodes from within a Python script? For example, I have a script for an enemy that will follow a Node2D target, and for testing purposes, here is how I have it set up to print the target node's position:
But
self.get_node()
returns aNode
, so as a result, I can't access the position and get this error:AttributeError: 'py4godot.classes.Node.Node.Node' object has no attribute 'position'
Is there a way to get the node type from
get_node()
? Or is there another way to access other nodes?