I've got a timer in my game which is supposed to set off a Boolean back to false after a certain amount of time has passed it just doesn't seem to work despite me trying to debug the issue, although setting off the timer works perfectly fine. Any help with this would be much appreciated
for (int i = 0; i < cameras.Count; ++i)
{
DetectCamera camera = cameras[i];
Stopwatch camTimer = new Stopwatch();
if (player.InterferenceStart && player.EMPBoundingCircle.Intersects(camera.BoundingRectangle))
camTimer.Start();
if(camTimer.ElapsedMilliseconds >= 2000.0f)
{
camera.CameraInRange = false;
camTimer.Reset();
}
else if (camTimer.IsRunning)
camera.CameraInRange = true;
}
GameTime.ElapsedGameTime
in yourUpdate
function to provide timing (to count up some time, for a delay, you'd accumulate it in a variable). \$\endgroup\$