Hi,
I’m new in unity3d and i’m doing something wrong. How to use class in class? I write code like this and i can’t initiate class Player with values in Stat class fields.
var player : Player;
class Stat{
var current: int;
var max: int;
}
class Player{
var name: String;
var hp: Stat;
var mana: Stat;
var attack: int;
var defense: int;
function Player(name: String, hp: int, hpMax: int, mana: int, manaMax: int, attack: int, defense: int){
this.name = name;
this.attack = attack;
this.defense = defense;
this.hp.current = hp;
this.hp.max = hpMax;
this.mana.current = mana;
this.mana.max = manaMax;
}
}
function Start(){
player = new Player("PlayerName", 10, 20, 10, 20, 99, 99);
}
How to set values to hp.max, hp.current, mana.max and mana.current?
How to do it right?