using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class statroll : MonoBehaviour {
void Start() {
for(int x = 0; x < 20; x++)
{
int str, agi, inte;
int statroll = Random.Range(1,3);
switch (statroll)
{
case 3:
str++;
break;
case 2:
agi++;
break;
case 1:
inte++;
break;
default:
Debug.LogError("Something went wrong, probbably with my Random.Range bounds!");
x--;
break;
}
}
}
}
It’s telling me that line 16 is using an unassigned local variable, when I clearly assigned it.
Thank you, what I’m trying to do is to make dice rolling button that randomizes your stats, so should strength, intelligence and agility be public variables, since I’m gonna use them in the future? I’m not sure.
I would start off by adding them as private, as you dont want them to be altered outside of the class, and then make them read only when needed, but as Enderkill9 said, thats a new thread