Invalid get index 'zoom'(on base: 'null instance')

Godot Version

4.2.2

Question

I am beginner so sorry for this probably stupid question; I’ve written a code to allow player to zoom in/out their camera and it worked in previous backup of my game and now it isn’t. I did not changed anything related to this script, i’ve done some research but nothing seem to be helpful for me, could someone help?

this happen because the camera_2d is not yet ready, so it’s null
try add

await get_tree().physics_frame

at the first line of zoom() function

if this doesnt work, then you can just

add

if not camera_2d:
	return

at the first line of zoom() function

1 Like

second solution worked, thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.