I’m having a problem on getting some resutls.I have 2 scenes.In the first scene i have my player with his stats and in the second scene i want my player to fight a pc bot player with some stats i have given to it.The problem is that my player is always winning even if the pc bot player is stronger.Any ideas?
Here is the code:
public int level;
public string name;
public int health;
public int attack;
public int def;
public int atc;
public int df;
public int hp;
public void OnMouseDown()
{
atc = statsTextsToDisplayAndChanges._INstance.attack;
df = statsTextsToDisplayAndChanges._INstance.def;
hp = statsTextsToDisplayAndChanges._INstance.health;
if (attack+def+health <= atc+df+hp)
{
Debug.Log("YOU WON");
}
else
{
Debug.Log("YOU LOST");
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class statsTextsToDisplayAndChanges : MonoBehaviour
{
public static statsTextsToDisplayAndChanges _INstance;
buyWeapons bw;
public Text m_LevelText;
public Text m_AttackText;
public Text m_DefendText;
public Text m_MoneyText;
public int level;
public int money;
public int health;
public int attack;
public int def;
string answer;
string url = "http://alex3685.dx.am/display.php";
private GameObject _Manager;
public int sword1 = 200;
public int sword2 = 300;
public int sword3 = 400;
public int sword4 = 600;
public int sword5 = 750;
public int sword6 = 900;
public int shield1 = 200;
public int shield2 = 200;
public int shield3 = 200;
public int shield4 = 200;
public int shield5 = 200;
public int shield6 = 200;
public void Start()
{
if (_INstance == null)
{
_INstance = this;
DontDestroyOnLoad(this.gameObject);
_Manager = GameObject.Find("playerStats"); // gia na allazei tis metavlites otan agorazei apo to shop o xristis!
}
else if (_INstance != this)
{
Destroy(gameObject);
}
display();
}
public void display()
{
m_LevelText.text = level.ToString();
m_AttackText.text = attack.ToString();
m_DefendText.text = def.ToString();
m_MoneyText.text = money.ToString();
}
lol well I just don’t see how that’s not working. If you print out the values in the function for MouseDown, what does it print out? This should be pretty simple
i added some values for attack def and health on my function OnMouseDown and it works now.Strange though that it didn’t worked when i added the values from the inspector.Thanks for the tip though it helped me solve it
Well, that’s only sort of good , because it should work the other way lol.
When you’re in that scene and you look in the inspector, are the values still correct while you’re playing?
I mean , if it’s working well enough you can forget about it… but if you want to try to solve it more, it’s up to you