Hi there,
I am currently working on a simple JRPG combat system and I have sprites being instantiated and I need to be able to access the individual stats of said sprites so i can check who gets to go first in combat (roll for initiative).
Basically I will have a separate function which will determine who goes first in combat and then combat damage will be determined. If anyone can tell me what I’m doing wrong i have tried the GetComponent/s function however it does not want to work. Looking around on google I couldn’t find a solution to my problem.
Edit** I forgot to mention Stats are currently a baseline of 12 and are available in another script called CharacterStats. The stats do get set for each sprite I just need to be able to access them in code.
Thanks in Advance.
void SpawnIn()
{
for (int heroSpawnPoint = 0; heroSpawnPoint <= 2; heroSpawnPoint++)
{
int heroNum = Random.Range(0,4);
hero[heroSpawnPoint] = Instantiate(heroPrefab[heroNum], spawnPoints[heroSpawnPoint].transform.position, Quaternion.identity);
GameObject currentHero = hero[heroSpawnPoint];
/* Character is instantiated and put in the hero array
* Characters stats are assigned in CharacterStats.cs
* Attempt to pull initiative from characters stats
*
*/
}
for (int enemySpawnPoint = 3; enemySpawnPoint <= 5; enemySpawnPoint++)
{
int heroNum = Random.Range(0, 6);
enemy[enemySpawnPoint - 3] = Instantiate(enemyPrefab[heroNum], spawnPoints[enemySpawnPoint].transform.position, Quaternion.identity);
}
}
void Attack()
{
//compare enemy and PC initiative scores and deal dmg.
}