Greetings everyone, good evening! It’s great to be back. I finally set aside some time to continue working on my project, but I’ve encountered an issue with the script. Despite having studied it a few times, I still feel more confident following tutorials.
Here’s the first problem I’ve come across. I followed this tutorial for a camera and got stuck at the part where I need to “link” the player node to the script. I’ve tried various methods (such as get_node(“Player”)), but none of them have worked. The only changes I made to the tutorial were to translate some of the variables and annotations into portuguese, my native language. As far as I can tell, the error is not related to the variable names.
However, whenever I run the code, I get the error “cannot call method ‘get_position’ on a null value.” I believe this is because the script is unable to “link” with the other node. All of the nodes are in the same scene, and they function individually (the camera without customization and the character’s movement). So, what should I try now?
Here are some code snippet - I think the issue is there.
P.S: I’m currently focusing on creating a transition within the same scene before moving on to multiple scenes and transitions. Any additional advice is always appreciated, as I’m still a beginner.
It makes an independent scene couple with another scene. It is no longer independent, and is the reason that made you have to came here.
Get node should be limited to use if it’s within a scene internally and the node is static.
Or if you have need to, but do the proper null checks.
I think it’s cumbersome to do null checks before interacting with an object, so I try and avoid ever letting that object reference be null by planning my code and organization.
Having an export object is for this design pattern is great as long as you set the property it should work. You can even have an editor warning to remind you.