Calling variabels from classes.

Hi been trying out classes for a couple of hours or so. But i have run into a problem that i cannot seem to be able to fix.

This is one script i got. With this way in the inspector i can have a foldout with another foldout with more variables which makes things much easier to find and set variables to. But i need to learn how to call variables from the Movement class. So basicly the class within the class(classception?).
Anyone know how i go about this?
Would also be good if you could show how to do this from another script too.

class EnemyClass 
{
	var Health : float;
	var moveSpeed : float;
	var normalMoveSpeed : float;
	var Movement : Movement[];
}
class Movement
{
	var Name : String;
	//Want to be able to call this.
        var moveSpeed : float;
	var normalSpeed : float;
}
var Enemy = new EnemyClass();

//Randomly

Id start your variable names lower case to keep a consistent naming convention , class names capitalized.

It looks like EnemyClass has an array of Movement in there as well ?

But you would call something like

var speed = enemy.movement.moveSpeed;

Is that what you mean ?

Thats is not working i have tried that before. The movement array consists of the class Movement, so everything in the movement script will turn up in the array and therefore end up in the fold thingy in the EnemyClass. In the inspector.

Is that your all your actual code above or just a representation of what you’re doing ?

Your question isn’t very clear, let me try to clarify.
You are trying to access the moveSpeed variable of a specific instance of your movement class?

Since your enemy class has an array of them (why is that? Wouldn’t an enemy only need one instance of this class?) you need to make sure it is populated (so the same way you created a new instance of the enemy class you’ll need at least one instance of the movement class and have it stored in that array.

So at a quick guess something like:
EnemyClass enemy = new EnemyClass();

// I’d have the next part in a Start() function in the EnemyClass class. But for now:
enemy.Movement[0] = new Movement();

// then you’d access it as so
Float speed = enemy.Movement[0].moveSpeed;

I think that’s what you’re asking.

A couple of notes though:
Deginitely find a naming convention and stick to it. Try not to use class in the name of a class unless you do it every time (which is just annoying after a while). Use capitals to start class or function names and lower case for variable names.
Think about using struts if you just want a collection of values or data. So if a class doesn’t need any functions you can probably get away with a struct which I believe Is more memory efficient.
Think carefully about the array. I don’t know what your enemies do, but I can’t think of a reason for an enemy to have more than one instance of that class (or struct).

The struct could even be defined inside the enemy class.

class Enemy
{
struct MoveData
{
// some variables
}
MoveData move;
}

I hope that was helpful, I’m on the iPad and I’m still getting used to navigating these text boxes

*edit
Ah, I see what you’re trying to do with the movement data, it is the movement in different situations. I’d say definitely a struct, everything else I said still applies unless I misunderstand what you’re doing.

Now that i think about it i’m not sure why i used arrays, did not really think about it that much. Dont make that much sense now that i think about it.
You say that structs are good for just storing data. How is it structs work? Can you explain how they can be used or do you know a good tutorial which can explain it for me?