using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Stat
{
[SerializeField]
private int baseValue;
public int GetValue ()
{
return baseValue;
}
}
Basically I made a custom class called Stat.
I made a variable in another script:
namespace SG
{
public class CharacterStats : MonoBehaviour
{
public int maxHealth;
public int maxMagicPower;
public Stat maxMeleeDamage;
}
}
And I want to use the maxMeleeDamage variable in this code:
public class AttackScript : MonoBehaviour
{
public GameObject HitParticle;
private GameObject player;
private int damageDealt;
public bool melee;
public bool ranged;
public bool magic;
public int magicPowerDrain;
private Collider enemy;
private void Start()
{
player = GameObject.FindWithTag("Player");
if(melee)
{
damageDealt = player.GetComponent<PlayerStats>().maxMeleeDamage;
} else if (ranged)
{
damageDealt = player.GetComponent<PlayerStats>().maxRangedDamage;
} else
{
damageDealt = player.GetComponent<PlayerStats>().maxMagicDamage;
}
}
}
But It says “Cannot implicitly convert Stat to int”. So idk what to do?