I have objects that are supposed to be spawning on top of their parent object, the code to do so is:
for (int i = 0; i < gridSquares.Length; i++)
{
for (int j = 0; j < gridSquares[i].Length; j++)
{
gridSquares[i][j] = new Vector3(transform.position.x, inventory.transform.position.y + 0.1f,
transform.position.z);
inventorySlot[i][j] = false;
}
}
I’m pulling from this code in another script, which is where the actual position is determined
transform.position = ptrInventoryScript.gridSquares[i][j]
however, everything that is spawning, is spawning incorrectly. Like in this picture, those two objects on the grid have the same X coords and yet they are at different spots. I don’t get why it’s doing this. It should be displacing by the transform of the gridsquares*[j], but it doesn’t seem to do that (or at least not properly).*
One thing I have noticed is that they do seem to be spawning at the right world coordinates, which is why I think they are not in the same spots (since I am moving to pick up a new object to put in the grid). However, I have NO idea why it’s using world coordinates instead of local. I tried using localposition instead of position, but that gave me the same issue, except WAYYY far away from my grid’s location.
I’ve had this issue for like a day now and I can’t figure it out, please, someone help me out here.