When I should use Vector3 ?

Hi all,

I’m wondering if I should or not using Vector3 in some cases, It seems obvious for positions, but not for things like that:

int indexX, indexY, indexZ
//Or simply:
Vector3 index; //and get x, y, z by Vector3's properties (and yes, I know they are float and not int)

Or since I’m using a lot of 3D int data, maybe I should write a kind of Int3D struct ?

I would only use Vector3’s if they are relating to a vector. Don’t use them to just hold 3 variables. That is what arrays are for.

if the x,y,z are coordinates you plan to use like a vector then you can use the vector.

If you have need for a 3d int construct. I’d create a 3d int struct.

public struct Int3d
{
    public int x;
    public int y;
    public int z;
}

It defines a specific use 3d construct. It takes up the same amount of space as an array of size 3, but when you receive this you KNOW it’s of size 3, no bigger, no smaller.

Ok, I think I’ll use struct as I’ve said before, thanks to both of you. (and by the way, it’s completely mad to use an array in this case, don’t do that, never ! ^^).

Only thing to remember with the Int3d struct is that structs don’t get serialized by Unity.