- Home /
How to create a list from Children with different variables
I'm looking to test my skills by making a card game of sorts.
The cards are currently being stored in a parent object "Play Area", they have come from "Player hand" and I am looking for a way to have a script enact the moves of all the different cards once the player ends their turn.
The way I can think of this is having the card hold an index number and a manager gather all of the index numbers into a list. The code will then go through the list enacting all of the cards' moves. However, I can't think of a way of accessing a changing number of cards without using a generic tag, however, this would access the cards that have not been played. This is all being done as a user interface, on the canvas.
Can you be a bit more clear on what you want to do? You can get all children of a gameObject and put them in a list in Start or OnEnable. I'm not sure what you want to do beyond that.
Answer by afraism · Feb 04, 2021 at 06:13 PM
I did not quite understand what you meant, but as far as I understand from your explanation, you have to consider a script for the card, which has an ID, when you clone the cards, you have to set those IDs, Also, keep the script of those objects in a list that is actually responsible for saving these cards, and this way you will have access to all the cards. If my understanding of the subject is correct and you need an example, tell me.
Your answer
Follow this Question
Related Questions
Making a list of obect's parents their parents from one script. 0 Answers
Having trouble making headshots do more damage (JS) 1 Answer
Convert tags to list, then back to array 1 Answer
Looking for help with Scrolling List / rows for tv UI ( via game controller) 0 Answers
Using similar to GameObject.FindObjectsWithTag but for tag.contains. 0 Answers