Forum begins after the advertisement:
[Part 15/16] New weapon system
Home › Forums › Video Game Tutorial Series › Creating a Rogue-like Shoot-em Up in Unity › [Part 15/16] New weapon system
- This topic has 5 replies, 2 voices, and was last updated 2 months ago by Terence.
-
AuthorPosts
-
February 14, 2024 at 7:22 am #13327::
So I’ve been playing around with the new weapon system and I came across some bugs. I don’t know it’s just me or everyone but: -New Player Inventory system: Player can have up to 6 weapons and if the number of available weapons (weapon data) are 7 or more, new weapon will show up when player already have 6 weapons in the inventory and it’s unclickable (because i already have 6 wps)
-Random growth is stacking up stats. For example I have knife(max lv8) 1-5 is linear and 5a, 5b, 5c is random growth. Stats from them will stack if upgrades pop up as 5c (stats in 5c will become 5a+5b+5c instead)
February 14, 2024 at 10:31 am #13328February 17, 2024 at 8:06 am #13340::My bad on the first one, I set the weapon slots and passive slots to 6 (i don’t remember how), but still, new weapons show up when the weapon slots are full
February 17, 2024 at 1:06 pm #13341::Hi Kai, below is a quick temporary fix. I will be addressing this issue in Part 18 of the series.
// Finds an empty slot and adds a weapon of a certain type, returns // the slot number that the item was put in. public int Add(WeaponData data) { int slotNum = -1; // Try to find an empty slot. for(int i = 0; i < weaponSlots.Capacity; i++) { if (weaponSlots[i].IsEmpty()) { slotNum = i; break; } } // If there is no empty slot, exit. if (slotNum < 0) return slotNum; else if(slotNum > 5) return -1; // Otherwise create the weapon in the slot. // Get the type of the weapon we want to spawn. Type weaponType = Type.GetType(data.behaviour); if (weaponType != null) { // Spawn the weapon GameObject. GameObject go = new GameObject(data.baseStats.name + " Controller"); Weapon spawnedWeapon = (Weapon)go.AddComponent(weaponType); spawnedWeapon.Initialise(data); spawnedWeapon.transform.SetParent(transform); //Set the weapon to be a child of the player spawnedWeapon.transform.localPosition = Vector2.zero; spawnedWeapon.OnEquip(); // Assign the weapon to the slot. weaponSlots[slotNum].Assign(spawnedWeapon); // Close the level up UI if it is on. if (GameManager.instance != null && GameManager.instance.choosingUpgrade) GameManager.instance.EndLevelUp(); return slotNum; } else { Debug.LogWarning(string.Format( "Invalid weapon type specified for {0}.", data.name )); } return -1; }
October 23, 2024 at 11:44 am #16149::Hi, I was wrong about random growth stacking stats, what actually happened was the description didn’t match the stats in random growth array. I am using random growth for every weapon levelup (level 1 to 8)
My weapon set up:
View post on imgur.com
October 23, 2024 at 10:59 pm #16154 -
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: