Godot Version
Godot 4.6.1.stable
Question
I have a script that tracks the position of the node it’s attached to. I am trying to reference said position from a different script. This isn’t working. I feel like I am missing something very simple, because I’m pretty sure I have done this before in the exact way I’m trying to do it now, and it worked fine.
The tracking script has been pasted in full, the referencing script is just the part that interacts with it.
Tracking script:
extends Node3D
class_name anchorpoint
var anchor : Vector3
func _physics_process(delta: float) -> void:
anchor = self.position
Referencing script:
extends CharacterBody3D
func _physics_process(delta: float) -> void:
look_at(anchorpoint.anchor)
print(anchorpoint.anchor)
This returns the following errors:
ERROR: res://scripts/player.gd:17 - Parse Error: Cannot find member “anchor” in base “anchorpoint”.
ERROR: res://scripts/player.gd:18 - Parse Error: Cannot find member “anchor” in base “anchorpoint”.
To my knowledge, this is how you’re supposed to cross-reference scripts without hassle. I’m assuming I’m missing an extension somewhere or I’ve made a typo, but I’m failing to see where I’ve gone wrong.
I’m using this system to orient the player model in the direction of the camera; essentially locking the player’s facing to a physical crosshair. There are other ways of doing this that are probably better, but right now I am exploring the limitations of this specific method of camera control.
