It lets you click torches in the dungeons to pick them off the wall and add them to your inventory. Making this took about 10 minutes and was easy-peasy.
In practice it deactivates the torch GameObject you clicked and inserts a torch item into your inventory.
Then came the problem: I can't figure out any way to save any identifying data about the torch gameObjects that can also be used to deactivate the dungeon torches upon loading a savegame.
At the moment, the only data I could find that at least fits, is the Vector3 position data for the torches. However, I can't for the life of me figure out a way to use the position data to find the GameObject in that position and manipulate it.
The closest I've gotten so far is this:
Code: Select all
private static void DouseTorches()
{
if (dousedTorches != null && dousedTorches.Count > 0)
{
List<GameObject> allUntaggedObjects = new List<GameObject>(GameObject.FindGameObjectsWithTag("Untagged"));
foreach (GameObject obj in allUntaggedObjects)
{
foreach (Vector3 torch in dousedTorches)
{
if (obj.transform.position == torch)
{
Torch = obj;
DouseTorch(Torch);
}
}
}
}
else
Debug.Log("Not running DouseTorches()");
}
So, am I way off in how I'm even trying to solve this? Is there another way to go about this?
GitHub link