In my killzone script, I just dragged and released with ctrl held to get the reference.
Are things running out of order, and therefore the reference isn’t found? I did the same method of referencing in another script and that seemed to work. I am confused as to why this one is a problem.
I am new to Godot, and am more used to UE5/Unity workflow, so I assume there is something fundamental I am not understanding with getting references in general…
Just remove the quotation marks from the $…/…/Camera2d locator. You keep importing improper documents from previous 3.x godot. Or, just plain making mistakes.
Removing quotation marks causes errors. The reference was setup the “correct” way - dragging from the scene tree and then releasing in the script while holding ctrl to create the reference.
Try using @export getting a node on ready from a parent is usually bad, the paren’t isn’t “ready” until all of it’s children are so you are trying to traverse a tree of un-ready nodes.
Another thing to add is some sort of filter, your “KillZone” will trigger if any body enters it, the TileMap counts as a body, the moving platform counts.You can add some filters by changing the collision layers and mask, or adding an if statement to only look for the player
func _on_body_entered(body: Node2D) -> void:
if body is Player:
camera_2d.StopFollow()
I get it. In this case you have to reference to the parent so it can fetch the code. Because this snippet will apply to the MainLevel node. KillZone is a reluctant child of another node. I think maybe it can’t grab all the resources. It’s got something to do with LocaltoScene properties. You’re definitely doing something wrong. Because you got your killzone set up. And, yet you’re still adding a CollisionShape2D as another child to KillZone. I don’t really think it’s a good practice to add children to nodes without reference. Even, maybe you can try to set the localtoscene property on the CollisionShape2D. It’s already out of place.
I think you might be confused about the architecture. All the programming categories have the same contents for Games. In C++, Early Basics and Java.
You make a window.
You add a subview port.
You fill the content of the view port.
You distribute the view ports on the screen.
That’s wy for example C++ looks demented in Games. It’s usually a lot of public classes that create the window, create view, create window, create view, create math, create view, create another reference for another public class that creates a variable, create view.
Okay. In the last attempt you’re just trying to get some attention here. There’s some remote limitation to capitalization and records of files and names. But, I do believe you hit GD:6. Which means your code references a node before renaming. Which now is calling a function from another scene and script.