Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Lowlande4k |
A function in a class extending Node has the following call:
var viewportWidth = get_viewport ( ).size.x
This works when the script is added to a node in the scene.
However, if the class is initialized as a var programatically (from a node that is part of the scene) it gives me the following error:
Invalid get index 'size' (on base: 'null instance').
How do I add the programatically-created node subclass to the viewport?