Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Omega8524 · Jul 16, 2021 at 04:32 AM · unity 2dcharactersrpg-game

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;
  
  
     }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

171 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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

Making a gameobject follow a player closely 1 Answer

I get this error when I want to print my 2d game as apk ,I get this error when I want to print my 2d game as apk 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges