I am currently working on a browser-based board game, and it is coming along fine. We are a couple weeks from entering a testing and fixing bugs phase, and something isn’t right with how I select my pawns to move around. Some of the times, they are selected with one click and sometimes it takes double or multiple clicks to select pawns. Same thing goes for when trying select a moveable location.
Here is a code sample on how I am selecting pawns:
function CheckIfPawnSelected() {
if(Input.GetMouseButtonDown(0)) {
var ray = camera.ScreenPointToRay(Input.mousePosition);
var hits : RaycastHit[];
hits = Physics.RaycastAll(ray, 200, -1);
for(var i=0; i < hits.length; i++) {
var hit : RaycastHit = hits[i];
for(var pawnsIndex = 0; pawnsIndex <= 8; pawnsIndex++) {
if(hit.transform.position == boardManager.pPawn[pawnsIndex].transform.position)
pawnNumber = pawnsIndex;
}
}
}
}
And a view of a testing scene for a visual:
On a side note, does anyone know why this happens?
When I sometimes open scripts in Unitron they will change the casing of the scripts. Just a minor frustration that I needed to vent.