![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | lowpolygon |
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.
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
lowpolygon | 2019-12-09 11:03
Try to use get_node("")
instead of $
.
The_Black_Chess_King | 2019-12-09 14:01
After reading this:
GDScript reference — Godot Engine (stable) documentation in English
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?
eod | 2019-12-10 08:53
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
lowpolygon | 2019-12-11 03:01