Attempt to call function' ' in base 'null instance' on a null instance?

Godot Version

Godot 4

Question

Im trying to create a button that when pressed will switch between Player 1 camera to player 2 camera. However in game when I go to click the button, the game crashes? Anyone know the correct way to set up cam switching? Best way I can describe what I mean is fnaf cams. Here are some photos for visual.

I wanna switch to player cam 2

Here is the code im trying to write


A simple switch of cameras on press…

Your script is attached to your LookLeft and LunchBox buttons, I’m guessing?

If so, then the crash makes sense. You’re referencing the is_current() method on a LookLeft/RigidBody3D/PlayerCam1, a node which does not exist.

So you’ll need to get the correct node reference into this code, or write it in a less brittle way (say, using signals).