Godot 4
Hi! I have few nodes, that are my prefabs. I include them inside the main script and then put them inside an array and dictionary (both methods are nort working) as variables. Then I tried to acces a specific variable’s position to move said node. Does it make sense? Unfortunetly it’s not working I am doing it this way because I try to randomly pick a variable, cos it’s supposed to be a memory game. In this example I am trying to move at least a specific card, because rest of the code that randomly picks cards works just fine. The error that I get is “Invalid set index ‘position’ (on base: ‘Nill’) with value of type Vector2”. I will appreciate all the help greatly!
@onready var card1a =$memory_card1a
@onready var card1b =$memory_card1b
@onready var card2a =$memory_card2a
@onready var card2b =$memory_card2b
@onready var card3a =$memory_card3a
@onready var card3b =$memory_card3b
@onready var card4a =$memory_card4a
@onready var card4b =$memory_card4b
var card_index = [card1a,card1b,card2a,card2b,card3a,card3b,card4a,card4b]
var c = ["1a","1b","2a","2b","3a","3b","4a","4b"]
var DicCards = { 1 : card1a,
2 : card1b,
3 : card2a,
4 : card2b,
5 : card3a,
6 : card3b,
7 : card4a,
8 : card4b
}
func _ready():
card_index[0].position = Vector2(200,600)