(I have split grabbing the slot and then accessing the prefab, but it should be the same as the course’s script)
To get the
InventorySlot we do this:
InventorySlot invSlot = transform.GetChild(activeSlotIndexNum).GetComponentInChildren<InventorySlot>();
and on this we do
GameObject weaponToSpawn = invSlot.GetWeaponInfo()?.weaponPrefab;
to get the prefab.
Now, in the hierarchy this is what we have (minus me having them prefabbed already):
So, shouldn’t the
GetChild() of the current slot index already give us the
InventorySlot which is exactly the object that has the
InventorySlot component on it?
So why should we have to do a
GetComponentInchildren<>() to grab it, then?
I would think
GetComponent<InventorySlot>() would be perfectly fine…
For some reason I also can’t even do that first swing down of the sword. I can run around and hit things though, as the weapon’s collider is active when the weapon gets spawned…
I hope that will be cleared when finishing the second half of this part and all the interactions between player and sword have been rebuild…