0 votes

I have always used $ to access objects in my scene. And this is my code

extends Weapon

onready var duration_timer = $timer_group/duration_timer

And that is inherited from :

extends Node2D
class_name Weapon

Codes above was fine the whole day. Until just now. All of a sudden
I am getting this msg :
Parse Error: Method 'get_node' is not declared in the current class

I can't figure what I did wrong. I didn't add anything new . And I have undo whatever I did and the same err message still appears.

in Engine by (169 points)

I did a bit more testing~~ once I comment out this static function,the error goes away, I am not sure why tho

static func instance_firing_muzzle(index,instance_position,parent_obj,array_to_add_to):
    if array_to_add_to[index] != null:
        return
    var tmp = wpn_muzzle.instance()
    tmp.position = instance_position
    parent_obj.add_child(tmp)
    array_to_add_to[index] = tmp

Try to use get_node("") instead of $.

After reading this:
http://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html#static-functions

It says: "it has no access to the instance member variables or self" perhaps that parent_obj reference is causing the issue. If you remove "static" and just make it a func, does it work?

yes,it did work once I took out the static function. But now whenever I press F5, Godot would just crash . My entire project is now screwed. Not game crash, but engine crash. I tried to comment out every line and still just crashed. I suspect I did something to screw the engine up

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.