Hi, bit of background to the problem: I’m creating a board game and I’m mainly using javascript. Each piece can be anywhere on the board. I’ve created a script, attached to my floor called “startup” that holds all these global class variables. Just like chess they are A5, B9 etc.
Each unit also has a script attached to it, telling it what moves are possible. I’m however having difficulty updating my global variables after a move has happened.
i.e accessing the script attached to the floor when doing
startup.B9
works fine.
But I dont know in advance what position each unit is at so I added another variable to the script attached to each unit called : “current_pos”
And this is where i’m having a big problem!! Referencing startup.current_pos
does not work as unity sees this entire call as a string. How can I force unity to see current_pos as variable that when I do startup.current_pos
it will actually send startup.B9
or whatever position the unit is on to the startup script and not startup.current_pos
Any help would be greatly appreciated.
if (skuif4_att_check == "none"){ i = 0.0; while (i < 1.0) { i += 0.08; animation.CrossFade("CrouchRun"); transform.position = Vector3.Lerp (transform.position, move4, i); yield; } animation.CrossFade("Crouch"); destroymove(); move_check = "empty"; current_pos = move4hit; //1 Debug.Log(current_pos); //2 Debug.Log(startup.M6); //3 Debug.Log(startup.current_pos); return;
1 = M6
2 = tank
3 = null
How can I go about fixing 3?
startup.js contains the following:
static var J1; static var J2; static var J3; static var J4; static var J5; static var J6; static var J7; static var J8; static var J9; static var J10; static var J11; static var J12; static var J13; static var J14; static var J15 etc....