Im using Unity Photon for teamplay multiplayer game.
I have 2 teams A and B. There is also a zone on the map, if you get into it (only to one team), then the timer decreases from 10 seconds and when the value is 0, a certain action occurs. This zone works through OnTriggerStay. I have difficulties with this: When one player enters this zone, then everything is ok, the timer tends from 10 seconds to 0 at normal speed, BUT, when another player from the same team comes in, then the timer passes twice as fast. I need a normal multiplayer countdown timer, for this zone, not the x2 multi-seconds.
private double _timeToNewScore = 10f;
private double _time;
private bool hasCapturedOne
private List <Health> team1players;
private void OnTriggerStay(Collider other)
{
if (hasCapturedOne)
{
foreach (Health p in team1players)
{
ScorePointsFromPeriod(1);
}
}
}
private void ScorePointsFromPeriod(int team)
{
_time += Time.deltaTime;
if (_time >= _timeToNewScore)
{
DoSomething();
}
}
Please, help me to avoid multiply seconds in timer, if there 2 teammates in zone. thx
PhotonNetwork.Timewhich is the same across clients? - JohnTube