In my script:
#pragma strict
var toon = false;
var player1steps : int = 0;
var player2steps : int = 0;
var shader1 : Shader = Shader.Find("Toon/Lighted Outline");
var shader2 : Shader = Shader.Find("Diffuse");
function Start () {
}
function Update () {
//gameObject.Find("PlayerControl").GetComponent(PlayerControl).player1Turn;
//gameObject.Find("PlayerControl").GetComponent(PlayerControl).player2Turn;
//gameObject.Find("PlayerControl").GetComponent(PlayerControl).player1End;
//gameObject.Find("PlayerControl").GetComponent(PlayerControl).player2End;
var diceHit : int = Random.Range(1, 7);
}
if(toon == true) {
renderer.material.shader = shader1;
if(gameObject.Find("PlayerControl").GetComponent(PlayerControl).player1Turn == true) {
if(Input.GetMouseButtonDown(0)) {
player1steps = player1steps+diceHit;
gameObject.Find("PlayerControl").GetComponent(PlayerControl).player1End = true;
}
}
//player2
if(gameObject.Find("PlayerControl").GetComponent(PlayerControl).player2Turn == true) {
if(Input.GetMouseButtonDown(0)) {
player2steps = player2steps+diceHit;
gameObject.Find("PlayerControl").GetComponent(PlayerControl).player2End = true;
}
}
}
if(toon == false) {
renderer.material.shader = shader2;
}
function OnMouseOver () {
toon = true; }
function OnMouseExit () {
toon = false; }
What this script does is, when i click on a specific object, then the player moves, and next i click player2 moves. But this really isnt the point. The point is:
It says at: player1steps = player1steps+diceHit; and player2steps = player2steps+diceHit;
It says: Assets/Scripts/Dice.js(30,29): BCE0005: Unknown identifier: ‘diceHit’.
Why cant it plus the diceHit with the variables?