Make an array with different variables...

I’ve got a problem with making an array with different variables(for an enemy). I want something like this: (it’s visual)

      What          Position          Lives          Level          type

      name           x,y,z              200            3              ground
      name           x,y,z              200            3              ground
      name           x,y,z              200            3              ground

How can i get this result. (i only know how to make one with one variables)…

Thanks…

You could make a class array and input those fields from inspector or hardcode those variables from script. I don’t think saving position would be a good idea though, as you will most likely place mobs randomly across the map, so position for each of them would be different.

[System.Serializable]
public class Enemy{
    public string thisName;
    public Vector3 thisPosition;
    public int lives;
    public int level;
    public string type;
}

public Enemy[] enemyList;

note : you havn’t specified the programming language you use, all my examples are in uJS

Create your own class :

public class EnemyClass
{
	public var name : String;
	public var position : Vector3;
	public var lives : int;
	public var level : int;
	public var type : String;
}

Then in your script, declare a class like this :

var enemy1 : EnemyClass;

You can assign values through script :

enemy1.name = "Marauder";
enemy1.position = Vector3( 10, 0, 20 );
enemy1.lives = 200;
enemy1.level = 3;
enemy1.type = "ground";

or simply assign them in the inspector

You can also make an arry of the enemy class :

var enemies : EnemyClass[];

Try it out. Create a new script, attach it to an empty gameObject in a new scene.
In the inspector, set the size of the enemies array, then fill in all the information :

public class EnemyClass
{
	public var name : String;
	public var position : Vector3;
	public var lives : int;
	public var level : int;
	public var type : String;
}

var enemies : EnemyClass[];

function Start()
{
	for ( var i : int = 0; i < enemies.Length; i ++ )
	{
		Debug.Log( "enemies[" + i + "].name = " + enemies*.name );*

_ Debug.Log( “enemies[” + i + "].position = " + enemies*.position );_
_ Debug.Log( “enemies[” + i + "].lives = " + enemies.lives );
Debug.Log( “enemies[” + i + "].level = " + enemies.level );
Debug.Log( “enemies[” + i + "].type = " + enemies.type );
}
}*_

I think 5 different arrays would be suitable, a string, a Vector3, two ints and another string array.