'get_local_mouse_pos' help!

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By harbor
:warning: Old Version Published before Godot 3 was released.

Hey all,

To familiarize myself with Godot, and to hopefully pick up some basic GDScript knowledge, I’ve recently started to make my own Pong game, guided by a nice YouTube tutorial. It’s very fun so far, but I’ve hit my first roadblock.

First off, here is my entire script so far –

extends Node
var player
var opponent
var ball

func _ready():
    player = get_node("Player")
    opponent = get_node("Opponent")
    ball = get_node("Ball")
    set_fixed_process(true)

func _fixed_process(delta):
    player.set_pos(Vector2(player.get_pos().x , get_local_mouse_pos().y))

Here is where I’m stuck – I’ve been thrown this error message:
Invalid call. Nonexistent function 'get_local_mouse_pos' in base 'GDNativeClass'.
I’m confused by this. In the tutorial (here) it works perfectly for him, and it is not an old video – published in late January of this year.

So, if anyone would be kind enough to help me out… where have I gone wrong?

:bust_in_silhouette: Reply From: Akien

The problem is that you wrote extends Node when it should have been extends Node2D.

The get_local_mouse_pos function comes from CanvasItem, which is inherited by Node2D.

Maybe docs could add an “Inherited properties and functions” collapsed section, like flixel.group.FlxTypedSpriteGroup - HaxeFlixel API

eons | 2017-04-27 14:20

Well there’s already the inheritance path, with clickable classes so you can get to their documentation: Node2D — Godot Engine (latest) documentation in English

But it could be made a bit more obvious yes, add a generic message to all pages that more methods and properties are inherited from [insert inheritance tree again], as it can indeed be overlooked by newcomers.

Akien | 2017-04-27 14:24