Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Yozzik |
Hey Guys.
In my project I have a MapPath:
extends Resource
class_name MapPath
@export var id: String
@export var name: String
@export var links: Array[MapPathLink]
var active_link: MapPathLink
Also MapPathLink:
extends Resource
class_name MapPathLink
@export var id: String
@export var name: String
@export var origin: MapPoint
@export var destination: MapPoint
And a MapPoint:
extends Node2D
class_name MapPoint
@export var id: String
@export var town_data: Resource
MapPoints are present on the scene, but MapPath is not set from the beginning. My problem is that when I set a MapPath, it has MapPointLinks, but their origin and destination variables are null.
func set_path():
current_path = load("res://tres/map_path/mp_001.tres")
current_path.active_link = current_path.links[0]
To me it looks like MapPathLink resources are being loaded before the scene and thus can’t reference any MapPoint. I can set origin and destination to String and put MapPoint.id there and then just search for an instance, but I’m sure there is a better way.
I just don’t know how to do it properly. Can anyone please help?