List instance is always the same as the blueprint ?
Hello ! I've been debuging a script for my game for about 3-4 hours now... yeah... i waisted some time... the script is a pathfinding script and i am using lists to find possible ways of going to certain spots
here is my code, let me explain the problem
List<GameObject> listOfTheCurrentPathR = new List<GameObject>();
listOfTheCurrentPathR = listOfTheCurrentPath;
List<GameObject> listOfTheCurrentPathL = new List<GameObject>();
listOfTheCurrentPathL = listOfTheCurrentPath;
List<GameObject> listOfTheCurrentPathU = new List<GameObject>();
listOfTheCurrentPathU = listOfTheCurrentPath;
List<GameObject> listOfTheCurrentPathD = new List<GameObject>();
listOfTheCurrentPathD = listOfTheCurrentPath;
NewGoRight(x, y, movementLeft, listOfTheCurrentPathR);
NewGoLeft(x, y, movementLeft, listOfTheCurrentPathL);
NewGoUp(x, y, movementLeft, listOfTheCurrentPathU);
NewGoDown(x, y, movementLeft, listOfTheCurrentPathD);
i have a maximum movement of 4. When i launch the following code, the "listOfTheCurrentPath" has 3 GameObject in it. So all the other instances (listOfTheCurrentPathR,L,U,D) also have 3 GameObjects on them. First, the code will run the NewGoRight function and pass in a few parameters, but the one that i am focusing on is the listOfTheCurrentPathR parameter. In this function, i add a GameObject in this list. The problem is, for some reason, that when the GameObject is getting added on listOfTheCurrentPathR, it also is gettings added on every instance of the listOfTheCurrentPath, and listOfTheCurrentPath itself...
Is this a bug or am i doing something wrong ?
if i am please let me know :)
thank you !
Your answer
Follow this Question
Related Questions
How to remove an item from a list of custom variables 1 Answer
Insert string into empty list at a specific index 0 Answers
Adding a unique element from one list to another list 2 Answers
Get all Children of an Object with a certain component 0 Answers
I need help finding the index of an object in a list. 1 Answer