I am getting

public List<GridPosition> GetValidActionGridPositionList()
    {
        List<GridPosition> validGridPositionList = new List<GridPosition>();

        GridPosition unitGridPosition = unit.GetGridPosition();
        for (int x = -maxMoveDistance; x <= maxMoveDistance; x++)
        {
            for(int z = -maxMoveDistance; z <= maxMoveDistance; z++)
            {
                GridPosition offsetGridPosition = new GridPosition(x, z);
                GridPosition testGridPosition = unitGridPosition + offsetGridPosition;
                Debug.Log(testGridPosition);
            }
        }

        return validGridPositionList;
    }

I am getting this issue x and z is getting 0 assigned at x = -maxMoveDistance and z = -maxMoveDistance

It appears your maxMoveDistance is set to 0. Make sure you have values assigned to it in the inspector.

2 Likes

But if there is a default value of 4, assigned in the script then why wouldn’t the inspector pick that?

It would if you added the default value first. But once the inspector has a value, the code will not make a difference. For that specific instance, that is

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms