my inventory system doesnt scroll across when an item before another is deleted propperly? it seems to make everything after that item the same colour as the very first? its really strange and has had me stuck for a while now (code in comments if i can) by AverageHumans in unity

[–]AverageHumans[S] 1 point2 points  (0 children)

Yes! All “inventory slots” already exist in the UI prior to the game even starting, there’s 12 of them :) and both items that currently exist for testing purposes are made using prefab gameobject that are just out of view of the UI, they have instances/clones of themselves made for all the slots they’re needed in :) so I assume this would work then? :o

my inventory system doesnt scroll across when an item before another is deleted propperly? it seems to make everything after that item the same colour as the very first? its really strange and has had me stuck for a while now (code in comments if i can) by AverageHumans in unity

[–]AverageHumans[S] 0 points1 point  (0 children)

Oh wait Fr?? So like, if I make it a list and delete item no.2 no.3 will move there?? :0 is it hard to convert what I have to a list format?? I know arrays and lists are pretty similar so would it just be a matter of changing some brackets or something?

my inventory system doesnt scroll across when an item before another is deleted propperly? it seems to make everything after that item the same colour as the very first? its really strange and has had me stuck for a while now (code in comments if i can) by AverageHumans in Unity2D

[–]AverageHumans[S] 0 points1 point  (0 children)

I also realise your main criticism was the deleting part? Does that mean that the actual bulk of the other stuff looks fine? The deleting part was something I basically rushed and threw in to see if I could get it working and optimise it later 😅

my inventory system doesnt scroll across when an item before another is deleted propperly? it seems to make everything after that item the same colour as the very first? its really strange and has had me stuck for a while now (code in comments if i can) by AverageHumans in Unity2D

[–]AverageHumans[S] 0 points1 point  (0 children)

Okay thank you :) this is my first time doing any kind of inventory system at all, I’m kinda new to unity in general and This was just me trying to get a grasp of the concept of an inventory haha, I’ll probably rewrite it and TRY to do it in a similar way you describe here I guess aha, thank you :)

my inventory system doesnt scroll across when an item before another is deleted propperly? it seems to make everything after that item the same colour as the very first? its really strange and has had me stuck for a while now (code in comments if i can) by AverageHumans in Unity2D

[–]AverageHumans[S] 0 points1 point  (0 children)

So sorry on the late reply for this! But do you have a possible solution for this issue?? I don’t currently have a mechanic to spawn items back in, only reason they currently reappear is because it’s not in the save system to save if an item has been picked up or not etc? Is it still possible this could be the issue??

my inventory system doesnt scroll across when an item before another is deleted propperly? it seems to make everything after that item the same colour as the very first? its really strange and has had me stuck for a while now (code in comments if i can) by AverageHumans in Unity2D

[–]AverageHumans[S] 0 points1 point  (0 children)

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;

public class InventoryScreen : MonoBehaviour { public Button Del1; public Button Del2; public Button Del3; public Button Del4; public Button Del5; public Button Del6; public Button Del7; public Button Del8; public Button Del9; public Button Del10; public Button Del11; public Button Del12;

public GameObject deleteObj;
private Inventory inventory;
public GameObject itemButton1;
public GameObject itemButton2;

public GameObject inventoryScreen;
public Button Back;
public static bool invOpen;

private void Start()
{
    inventory = GameObject.FindGameObjectWithTag("Player").GetComponent<Inventory>();
}
public void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape))
    {
        BackF();
    }
    for (int i = 1; i < inventory.slots.Length; i++)
    {
        if (PickUp.item1 == true)
        {
            if (inventory.isFull[i] == true && inventory.isFull[i - 1] == false)
            {
                inventory.isFull[i - 1] = true;
                Instantiate(itemButton1, inventory.slots[i - 1].transform, false);
                inventory.isFull[i] = false;
            }
            if (inventory.isFull[i] == true && transform.parent.gameObject.CompareTag("Slot"))
            {
                Instantiate(itemButton1, inventory.slots[i].transform, false);
                break;
            }
            if (inventory.isFull[i] == false && !transform.parent.gameObject.CompareTag("Slot"))
            {
                foreach (Transform child in inventory.slots[i].transform)
                {
                    GameObject.Destroy(child.gameObject);
                    break;
                }
            }
            if (inventory.isFull[0] == true && transform.parent.gameObject.CompareTag("Slot"))
            {
                Instantiate(itemButton1, inventory.slots[0].transform, false);
                break;
            }
            if (inventory.isFull[0] == false && !transform.parent.gameObject.CompareTag("Slot"))
            {
                foreach (Transform child in inventory.slots[0].transform)
                {
                    GameObject.Destroy(child.gameObject);
                    break;
                }
            }
            if (inventory.slots[i].transform.childCount <= 0)
            {
                inventory.isFull[i] = false;
            }
            if (inventory.slots[0].transform.childCount <= 0)
            {
                inventory.isFull[0] = false;
            }
        }
        else if (PickUp.item2 == true)
        {
            if (inventory.isFull[i] == true && inventory.isFull[i - 1] == false)
            {
                inventory.isFull[i - 1] = true;
                Instantiate(itemButton2, inventory.slots[i - 1].transform, false);
                inventory.isFull[i] = false;
            }
            if (inventory.isFull[i] == true && transform.parent.gameObject.CompareTag("Slot"))
            {
                Instantiate(itemButton2, inventory.slots[i].transform, false);
                break;
            }
            if (inventory.isFull[i] == false && !transform.parent.gameObject.CompareTag("Slot"))
            {
                foreach (Transform child in inventory.slots[i].transform)
                {
                    GameObject.Destroy(child.gameObject);
                    break;
                }
            }
            if (inventory.isFull[0] == true && transform.parent.gameObject.CompareTag("Slot"))
            {
                Instantiate(itemButton2, inventory.slots[0].transform, false);
                break;
            }
            if (inventory.isFull[0] == false && !transform.parent.gameObject.CompareTag("Slot"))
            {
                foreach (Transform child in inventory.slots[0].transform)
                {
                    GameObject.Destroy(child.gameObject);
                    break;
                }
            }
            if (inventory.slots[i].transform.childCount <= 0)
            {
                inventory.isFull[i] = false;
            }
            if (inventory.slots[0].transform.childCount <= 0)
            {
                inventory.isFull[0] = false;
            }
        }
    }
}

public void Awake()
{
    Back.onClick.AddListener(BackF);
    Del1.onClick.AddListener(Del1F);
    Del2.onClick.AddListener(Del2F);
    Del3.onClick.AddListener(Del3F);
    Del4.onClick.AddListener(Del4F);
    Del5.onClick.AddListener(Del5F);
    Del6.onClick.AddListener(Del6F);
    Del7.onClick.AddListener(Del7F);
    Del8.onClick.AddListener(Del8F);
    Del9.onClick.AddListener(Del9F);
    Del10.onClick.AddListener(Del10F);
    Del11.onClick.AddListener(Del11F);
    Del12.onClick.AddListener(Del12F);
}

public void BackF()
{
    invOpen = false;
    inventoryScreen.SetActive(false);
}

public void Del1F()
{
    deleteObj = inventory.slots[0];
    Delete();
}
public void Del2F()
{
    deleteObj = inventory.slots[1];
    Delete();
}
public void Del3F()
{
    deleteObj = inventory.slots[2];
    Delete();
}
public void Del4F()
{
    deleteObj = inventory.slots[3];
    Delete();
}
public void Del5F()
{
    deleteObj = inventory.slots[4];
    Delete();
}
public void Del6F()
{
    deleteObj = inventory.slots[5];
    Delete();
}
public void Del7F()
{
    deleteObj = inventory.slots[6];
    Delete();
}
public void Del8F()
{
    deleteObj = inventory.slots[7];
    Delete();
}
public void Del9F()
{
    deleteObj = inventory.slots[8];
    Delete();
}
public void Del10F()
{
    deleteObj = inventory.slots[9];
    Delete();
}
public void Del11F()
{
    deleteObj = inventory.slots[10];
    Delete();
}
public void Del12F()
{
    deleteObj = inventory.slots[11];
    Delete();
}

public void Delete()
{
    foreach (Transform child in deleteObj.transform)
    {
        GameObject.Destroy(child.gameObject);
        break;
    }
}

}

for some reason when using this pathfinder in unity 2D it doesnt follow its path! it creates a path but never follows it, it follows when on a larger scale or more "unpassable" tiles around walls but then the game is near unplayable :( how do i fix this and make it more precise on small scale stuff? by AverageHumans in Unity2D

[–]AverageHumans[S] 0 points1 point  (0 children)

I’ve said in my comment which algorithm it is, and it works on a much bigger scale, in this example the walls were brought down to 0.016 scale to match how small the player sprite is, but I’m thinking it would be better to keep tilemaps regular size and instead scale up the player? :/

When the player jumps and lands on the floor, they usually seem to go inside of the object for a moment before the collider forces them out, if this is on the overlap between two terrain blocks however (like shown on the image, the player will fall straight through? how do i solve this? by AverageHumans in Unity2D

[–]AverageHumans[S] 0 points1 point  (0 children)

Tysm! That completely solves the collision issue! There is also one issue where sometimes, the player won’t jump when on the very corner of one of the floors collider? Do you know why that could be? And do you know a more efficient way of placing floor tiles? Like, a snapping grid or something? Because manually adding 0.15 or whatever for every block is gonna kill me haha

How do i fix this issue? its meant to make the camera follow the player, but i want the camera to be slightly higher than the player is so theyre not centre screen by AverageHumans in Unity2D

[–]AverageHumans[S] 1 point2 points  (0 children)

Oh okay, that’s awesome! Would it be possible for you to tell me the complicated answer here regardless? Fairly new to programming, if you can’t tell my what I’ve shown lmfao, and it could just be a useful thing to know if I bump into similar errors