Posted January 18, 2024 by Ben Marquez Keenan
#Bugfix
Ran into an annoying InvalidCastException recently – turned out that I had changed the type of a node from Node2D to Camera2D but without updating the attached script from
public partial class CameraMovement : Node2D
to
public partial class CameraMovement : Camera2D
This meant that when I would "get" this object, either by direct reference, or a helper method like GetViewport().GetCamera2D, it would fail the cast and spam an exception every frame.
It took me a while to spot it, partly because I'm working on this project so sporadically so I had completely forgotten the node type change, but it was a quick fix at least!
New build runs as expected, at last! Feel much better being unblocked.