Godot Version
4.6.stable.official [89cea1439]
Question
Hi I have this problem with resource in my game I can’t assigne value to var from resource in class body
this code works and normaly, project plays and var attack_speed prints correct value
extends Node2D
@export var Player_stats_local: PlayerStats
var atack_speed
func _ready():
atack_speed = Player_stats_local.Player_Base_Attack_Speed
print(atack_speed)
this also work fine
extends Node2D
@export var Player_stats_local: PlayerStats
var atack_speed
func _stats_recalculate():
atack_speed = Player_stats_local.Player_Base_Attack_Speed
print(atack_speed)
func _ready():
_stats_recalculate()
but this code gives me errors:
1Resource file not found: res://SCENES/main.tscn::jsldp (expected type: unknown)
2Can’t use get_node() with absolute paths from outside the active scene tree.
extends Node2D
@export var Player_stats_local: PlayerStats
var atack_speed = Player_stats_local.Player_Base_Attack_Speed
func _ready():
print(atack_speed)
my resource has name player_stats.gd and has this code
class_name PlayerStats
extends Resource
@export var Player_HP: int = 1
@export var Player_Base_Dmg: int = 20
@export var Player_Base_Attack_Speed: float = 1
@export var Player_Base_Attack_Range: float = 400
@export var Player_Base_Maximum_Targets: int =1
@export var Player_Base_Speed: float = 100.00
@export var Player_Base_Time: float = 35
I alerady tried:
delete .godot folder
change from forward+ to compatability
opening new project then open this project with problem
making new resource