Total newbie - not sure if this is possible, but really hoping it is. Apologies for if the question is confusing, I’m struggling with the vocab of programming.
I am using a multi dimensional array. I would like to use the value returned from a Raycast.hit (which will be “left”, “middle”, or “right”) in place of an index numbers. I have integer variables defined with the same words like this.
static public var left = 0;
static public var middle = 1;
static public var right = 2;
The function looks like this:
function clickHandler ()
{
var hit : RaycastHit;
Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit);
for(var i = 0; i < numberOfControls; i++)
{
if (masterControlTable[currentState][hit,i] == 1)
{
print(hit+ " triggered the ClickHandler in state " + currentState);
}
else if (currentState < numberOfControls && masterControlTable[currentState][0,i] == 0)
{
print("nothing to see here");
}
}
}
Is there any way to take the value of hit and use it as the value of the variable with the same name? That is, can I somehow make the string of “hit” call the variable?