Godot Version
← Godot 4 →
Question
← Hello everybody! I am very new to Godot and I’m trying to add instances of villages into the main scene/level with different, ehrm, properties I suppose? Like setting the name and population of each village’s instance. Now, what I’m guessing is that I am supposed to use metadata to add this data to each village’s instance. However, aside from an unrelated .name feature, it seems I’m doing something wrong. Let me add the code related to this specific example (adding an instance of a “village” scene into the main scene/level and setting the name and population, both of which are metadata).
var village = preload(“res://Village.tscn”)
var newvillage = village.instantiate()
newvillage.position = Vector2(x, y) ← I set x and y to random ints
newvillage.name = a random name
newvillage.pop = rng.randi_range(10, 50)
The last two are important. Firstly, although the .name setting seems to work fine, as it turns out, this is actually a different name setting from what I made in metadata using a string labelled “Name” with a capital N. Second is the one for pop, which is an int labelled “Pop” in metadata, and I’ve tried both with and without the capital P, neither of which have been successful so far.
Either I’m not setting metadata properly, or this is not a situation that calls for metadata at all. Unfortunately, although I’ve tried searching for more info on metadata all over the web, I’ve yielded little info, for Godot anyways. Should I set name and population by some other means, or do I set metadata in another way?
Any help that you all can give me is much appreciated!
→