Question by
ckddus1227 · May 14 at 05:41 PM ·
scripting problemscripting beginner
Ability selection system, random int overlap problem
I want to create ability select system like in Vampire Survivors.
But there is a problem - I have 3 buffDisplay
objects so there are 3 randomCnt
and it has overlapping same value sometime and i don't know how to solve this problem.
Help
public class AbilitySelect : MonoBehaviour
{
public BuffDatabase buffData;
public GameObject abilityPanel;
public BuffDisplay[] buffDisplay;
int randomCnt;
void Awake()
{
buffDisplay = abilityPanel.GetComponentsInChildren<BuffDisplay>();
}
void Update()
{
GetAbility();
}
public void GetAbility()
{
if (LevelSystem.Instance.expFull)
{
for (int i = 0; i < buffDisplay.Length; i++)
{
randomCnt = Random.Range(0, buffData.buffs.Count);
buffDisplay[i].buff = buffData.buffs[randomCnt];
buffDisplay[i].slotImage.sprite = buffData.buffs[randomCnt].buffSprite;
buffDisplay[i].buffText.text = buffData.buffs[randomCnt].buffDescription;
}
LevelSystem.Instance.expFull = false;
}
}
}
Comment
Your answer

Follow this Question
Related Questions
I need Function to be in other script 1 Answer
Physics2D.OverlapCircle working in Unity but not in build 0 Answers
Get color from ColorPicker and apply it randomly on GameObject 0 Answers
How can I make a float decrease when touched by a cube? 0 Answers
How do I get an audio clip to play at a specific time? 0 Answers