Hi. I’m trying to set up a voting system, I believe everything is set up correctly but the variables seem to have trouble actually synchronizing. My code is as follows.
Variables:
public int button1vote;
public int button2vote;
public int button3vote;
public int BTN1;
public int BTN2;
public int BTN3;
Button:
if (GUI.Button (new Rect (140, 70, 350, 50), quiz.Answer1))
{
button1vote += 1;
}
The difficulty with your current approach is ownership - who owns the GameObject with this script attached? Isn’t that player then the only one who can vote? Or do you have one GameObject per player, in which case you don’t need ints for the vote counters. So you could do it that way, just synchronizing an enum instead (the player’s current vote), and have the host gather the results and broadcast it out.
The game is largely text based with a voting system. Each player has the game object which allows them to vote. I’ve added an int counter so that the votes can be tallied up and calculated. I wouldn’t really know where to start with Enums, the only time I have used Enums is when I have been dealing with GUI states.