3

I have a waiting room in unity with photon and when there are enough players a countodown starts, only problem is if the master client is using IOS and they check notification or are not in the app then the game will never starts when it hits 0 until they come back in the game. Is there a way to run the code and force it to start while in the background?

If this is not possible can I use OnApplicationPause() to run code if the OnApplicationPause is more than a certain time(say 5 seconds). So basically if the user leaves for 5 seconds then I would kick them out of the scene and send them to another scene.

Thanks.

dj102
  • 33
  • 4

1 Answers1

2

I don't know about IOS Unity but in android, you can use a Service to run script in the background Start android service from Unity3D code

I think this is another way to solve your problem:

  • When OnApplicationPause() is called, you can send a signal to your server to run a timer.
  • When this timer reaching elapse time, your server will kick the pause guy out of room.

It would better if you run a timer in server instead of client (user's device not work well, there is some case that you can't handle, etc)

Nam Vi Nguyen
  • 83
  • 2
  • 8
  • Thanks for the help, unfortunately I am using photon servers and not my own so that option would not work and service is not possible on IOS. – dj102 May 27 '19 at 23:26