First, sorry for my bad english, i’m a french guy (tour Eiffel et baguette !)
So, for a personnal project i make a game where you control a carnivor plant by throwing his head in the level for eat some guy !
You can only throw him and when your plant velocity is over, a new plant grow at this point and you can throw him again !
Currently i program the plant system, i instantiate a checkpoint each time she don’t move and when plant dead by guy or void she teleport at last checkpoint, i instantiate a new plant each time i throw it, ennemy, point etc is already program BUT ! I want a system where you can choose between ALL the plant you create !
If you throw your plant 4 times, i want player can throw him again with the second or third plant he create (in fact create a list and player choose between all plant in the list for his starting point)
I’m a begginer and i dont understand how the List System work in c#… i saw the tutorial of Unity Dev but i don’t understand all the tuto =p
If someone can help me it would be so great =D
I can post my scripts but there are 8-10 scripts xD
What don’t you get about lists? a list contains your variables in a specific order. Here’s a simple sample of how to use lists:
using System.Collections.Generic;
List<GameObject> listOfGameObjects = new List<GameObject>();
public void AddObjectToList(GameObject objectToAdd)
{
// this adds the object at the end of the list
listOfGameObjects.Add(objectToAdd);
}
public void RemoveGameObject(GameObject objectToRemove)
{
// this assumes that the object is actually inside the list, otherwise, nothing happens (or maybe it throws an error, don't remember)
listOfGameObjects.Remove(objectToRemove);
}
public GameObject GetGameObject(int index)
{
// this returns the gameobject that exists at "index" position.
// This means, if index is 0, the first object added will be returned, 1 means the one after that and so on.
return listOfGameObjects[index];
}
How i can add to my list an instantiate plant and choose one of this plant with arrow for exemple (left previous plant right next plant) for throw my plant again at the same position ?
not sure if it’s clear but i want all my plant like a checkpoint and player choose the checkpoint for throw is plant again =)