Can't change stats of the current character
Hello,
By advance sorry for my english.
Well I try to do some little RPG with multiple characters(party system etc) and I'm struggling a lot.
Right now what I m trying to do is :when the next button or previous button is clicked stats of the previous/next character is displayed.
I already create a script in scriptableObject+scriptable objects themself where the stats of the players are stored,a small script with an array where are stored all the gameobjects containing the main script in which the scriptableObject is referenced. the script changing the array to ++ seems to work but the stats display itself is not done.
I tried many combinaison,I spent more than 10h on it today ,so I hope someone can help me.
I let you some element of my code here .
script of the button :
public class NextCharButton : MonoBehaviour {
public GameObject[] characterGroup;
private int currentCharacter;
public void NextScene(){
characterGroup [currentCharacter].SetActive (false);
if (currentCharacter >= characterGroup.Length - 1) {
currentCharacter = 0;
characterGroup [currentCharacter].SetActive (true);
} else {
currentCharacter++;
characterGroup [currentCharacter].SetActive (true);
}
}
// Use this for initialization
void Start () {
for (int i = 0; i < characterGroup.Length; i++) {
characterGroup [i].SetActive (false);
currentCharacter = 0;
characterGroup [0].SetActive (true);
}
}
main script(most important element) // playerstatsscriptable = ref to another script used for create the scriptableObject >>public class PlayerStats : ScriptableObject
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class StatsCharMenu : NextCharButton
{
//display character info in menuUI//
// general stats//
// public TextMeshProUGUI playerName;
public TextMeshProUGUI playerLevel;
public TextMeshProUGUI playerClass;
public TextMeshProUGUI playerRole;
public TextMeshProUGUI playerExpToNextLevel;
public Image playerFace;
public TextMeshProUGUI playercurrenthp;
public TextMeshProUGUI playercurrentmp;
public TextMeshProUGUI playercurrentsp;
public Image affinity;
// special stats//
public TextMeshProUGUI playerCurrentPhysicalDodge;
public TextMeshProUGUI playerCurrentMagicalDodge;
public TextMeshProUGUI playerCurrentPhysicalCounter;
public TextMeshProUGUI playerCurrentMagicalCounter;
public TextMeshProUGUI playerCurrentDexterity;
public TextMeshProUGUI playerCurrentFocus;
public TextMeshProUGUI playerCurrentCriticalChance;
public TextMeshProUGUI playerCurrentCriticalMultiplier;
// attack stats//
public TextMeshProUGUI playerCurrentPhysicalAtk;
public TextMeshProUGUI playerCurrentFireAtk;
public TextMeshProUGUI playerCurrentWaterAtk;
public TextMeshProUGUI playerCurrentWindAtk;
public TextMeshProUGUI playerCurrentEarthAtk;
public TextMeshProUGUI playerCurrentLightAtk;
public TextMeshProUGUI playerCurrentDarknessAtk;
public TextMeshProUGUI playerCurrentVoidAtk;
//defense stats//
public TextMeshProUGUI playerCurrentPhysicalDef;
public TextMeshProUGUI playerCurrentFireDef;
public TextMeshProUGUI playerCurrentWaterDef;
public TextMeshProUGUI playerCurrentWindDef;
public TextMeshProUGUI playerCurrentEarthDef;
public TextMeshProUGUI playerCurrentLightDef;
public TextMeshProUGUI playerCurrentDarknessDef;
public TextMeshProUGUI playerCurrentVoidDef;
//public TextMeshProUGUI
public PlayerStats playerstatsscriptable;
// Start is called before the first frame update
void Start()
{
// display info in GUI //
//infos générales//
// playerName.text = playerstatsscriptable.playerName;
playerLevel.text = playerstatsscriptable.level;
playerClass.text = playerstatsscriptable.playerClass;
playerRole.text = playerstatsscriptable.role;
playerExpToNextLevel.text = playerstatsscriptable.expToNextLevel;
playerFace.sprite = playerstatsscriptable.characterFace;
playercurrenthp.text = playerstatsscriptable.currenthp;
playercurrentmp.text = playerstatsscriptable.currentmp;
playercurrentsp.text = playerstatsscriptable.currentsp;
playerCurrentPhysicalDodge.text = playerstatsscriptable.physicaldodge;
playerCurrentMagicalDodge.text = playerstatsscriptable.magicaldodge;
playerCurrentPhysicalCounter.text = playerstatsscriptable.physicalcounter;
playerCurrentMagicalCounter.text = playerstatsscriptable.magicalcounter;
playerCurrentDexterity.text = playerstatsscriptable.dexterity;
playerCurrentFocus.text = playerstatsscriptable.focus;
playerCurrentCriticalChance.text = playerstatsscriptable.criticalchance;
playerCurrentCriticalMultiplier.text = playerstatsscriptable.criticalmultiplier;
playerCurrentPhysicalAtk.text = playerstatsscriptable.physicalatk;
playerCurrentFireAtk.text = playerstatsscriptable.fireatk;
playerCurrentWaterAtk.text = playerstatsscriptable.wateratk;
playerCurrentWindAtk.text = playerstatsscriptable.windatk;
playerCurrentEarthAtk.text = playerstatsscriptable.earthatk;
playerCurrentLightAtk.text = playerstatsscriptable.lightatk;
playerCurrentDarknessAtk.text = playerstatsscriptable.darknessatk;
playerCurrentVoidAtk.text = playerstatsscriptable.voidatk;
playerCurrentPhysicalDef.text = playerstatsscriptable.physicaldef;
playerCurrentFireDef.text = playerstatsscriptable.firedef;
playerCurrentWaterDef.text = playerstatsscriptable.waterdef;
playerCurrentWindDef.text = playerstatsscriptable.winddef;
playerCurrentEarthDef.text = playerstatsscriptable.earthdef;
playerCurrentLightDef.text = playerstatsscriptable.lightdef;
playerCurrentDarknessDef.text = playerstatsscriptable.darknessdef;
playerCurrentVoidDef.text = playerstatsscriptable.voiddef;
}
Your answer
Follow this Question
Related Questions
Convert movement direction into rotation? 0 Answers
Missing "add reference" button and error CS1703 0 Answers
i got a serious problem, help please 0 Answers