I’m looking to make a constructor of a character which contains a list variable. How would I add this?
class Character
{
var name : String;
var hp : int;
var attacks : List.<Attacks> = new List.<Attacks>();
function Contructor (nameNew : String, hpNew : int, attacksNew : Attacks)
{
name = nameNew;
hp = hpNew;
attacks = attacksNew;
}
}
class Attacks
{
var name : String;
var power : int;
}
function Start ()
{
var player : Character;
player.Constructor("ben", 10, ????);
// I want to add two entrys to attacks List with name "fireball" and power 10.
}