I’m still very unfamiliar with Unity, but I’ve been slowly absorbing how to go about things.
My question is about how to convert some techniques I had been using in ActionScript into Unity Javascript.
Particularly in regard to arrays.
In ActionScript, I was able to make an array of game item data like this:
var weap = [
{Name: "M16", Ammo: 2, Rng: 2, Acc: 50, Dmg: 60},
{Name: "M4", Ammo: 2, Rng: 2, Acc: 60, Dmg: 55},
{Name: "MP5", Ammo: 3, Rng: 1, Acc: 70, Dmg: 75}
];
This had a number of benefits, including ease of coding, and ease of referencing.
It’s organized, compact, labeled, easy to read, easy to compare and tweak values, etc. (Whereas a vertical listing of unlabeled data is a nightmare.)
When I want to reference values, it’s easy to call and clear to read.
For example, if I want to find the damage of weap index 2, all I had to do to is:
myDamage = weap[2].Dmg;
// returns 75
What’s the proper way to do this in Unity Javascript?
Which array type is best? Is this a 2D Array?