I don’t fully understand transform but get_global_transform() is getting the matrix for the node’s position and rotation. The error says “not declared on base ‘Transform’” because distance_to() needs to come after a Vector3 which would be Transform.origin.
I feel like this should be working, but I’m clearly not understanding something about distance_to.
Here’s what I put in for the variable after your explanation:
var distance2opponent = self.transform.origin.distance_to(get_node("/workspace/Player").transform.origin)
And although there is no errors right away, when I run the script it gives me an error saying: “Invalid get index 'transform' (on base: 'null instance')”
The debugger says it now can’t find my Player node.
This code is being put on a MeshInstance called “AI”.
My “Player” is also a MeshInstance. Both of them are children under the Spatial root “workspace”.
I don’t know what I’d doing wrong.
Dumuz | 2019-11-26 19:01
I also missed this, but get_node("/workspace... doesn’t need the slash. It should be get_node("workspace...