- Home /
Dimentional struct matrix
I'm trying to make a 3dimentional struct matrix. I think i have created the struct matrix, but im drawing a blank on how to fill it or get values from the struct matrix. I would like to access both Hvalue and Movementcost from f.eks matrixvalues[2,1,0] I have seen some examples where they fill it with information using something like
t[, ,] array3D= new int[,,]{{1,2,3},{4,5,6}}
but seing as this "struct array matrix" will be pretty big it would be a little inconvenient
public struct matrixvalues
{
public int Hvalue;
public int Movementcost;
};
public class Pathing : MonoBehaviour {
void HValue()
{
matrixvalues[, ,] matrix = new matrixvalues[7, 6, 0];
// access or set Hvalue and Movementcost to matrixvalues[1,1,0] // using [1,1,0]as an example
}
trying to make a 3Dimentional array where, each element have struct informention stored in them. Can't figure out how to access the struct from the array.
Example:
i want element [1,2,0] to have information about Hvalue and $$anonymous$$ovementcost. how do i access or write these values.
Your answer
Follow this Question
Related Questions
Bigger matrix? 3 Answers
Enum instead of numbers in arrays 1 Answer
How destroy a object and it's similars 4 Answers