Hi all,
I'm still learning and figuring out classes and scope etc.
I have the following:
class MoveState:
var bat
#init gets called when an object of this class gets created
func _init(bat):
self.bat = bat
#frame by frame update
func update(delta):
pass
#it's good to be able to handle input from within the state
func input(event):
#if event.is_action_pressed("ui_up"):
if event.type == InputEvent.KEY:
var mousePosition = get_viewport().get_mouse_pos()
On that last line I'm simply trying to find the mouse position. I get the following error though:
Invalid call. Nonexistent function 'get_viewport' in base 'Reference ()'.
I'm SURE it's to do with scope. How could I get the position from within this function then? I'm really struggling and have spent hours on this. Any help would be greatly appreciated. Brain is shutting down :-)