How to make a super simple network?

Hi all! How can I make a very simple network? I have an android application installed on several smartphones. I need to send a signal to other applications when I press one button in the application. I only need 1 function from the network.

I have little experience with PUN, but it gives a delay, I need something as fast as possible. So that you can transmit a network signal via Bluetooth or Wifi. What solution is worth exploring for this? Thank you.

Hi @DarkDeivel , you can achieve it by connecting all the clients either through a dedicated server service (more expensive, but reliable), or through a Relay server + NAT punchthrough (cheaper, but cheateable).
If the devices are all on the same local network, you can even use direct IP.

Once they're connected, you can use a networking framework like Netcode For GameObjects to send messages across them.

Does this answer your question?

2 Likes

check also Bluetooth networking
https://assetstore.unity.com/?q=bluetooth%20network&orderBy=1

2 Likes

When you say, gives a delay, how long as you referring? There will always be some delay due to data traveling over the network.


The question of cheating does not bother me in this matter. Thanks for the advice, I'll look into it.


Interesting, I'll look into that, thanks a lot.


Hello, I know, but the photon has more than it needs, because there is no direct connection.

1 Like

[quote=“DarkDeivel”, post:5, topic: 901430]
The question of cheating does not bother me in this matter. Thanks for the advice, I’ll look into it.

Interesting, I’ll look into that, thanks a lot.

Hello, I know, but the photon has more than it needs, because there is no direct connection.
[/quote]
Okay so you mean it’s going through their relay.
You’re going to have a delay no matter what, which of course will be marginally higher if using a relay or dedicated server.

If you want to connect to devices outside your network some sort of relay or NAT is going to be required.

From your original message I got the impression you’re open to other solutions. If you are looking to connect to devices on your own network consider giving FishNet a try. It has a network discovery addon just for this, which bypasses the need for a relay https://fish-networking.gitbook.io/docs/manual/general/add-ons
FishNet can also use relays and dedicated servers of course.

1 Like

The thing is, I'm a musician. I created a player in Unity that plays a metronome. Each musician has his own smartphone with headphones connected to it. I need one person to press the "PLAY" button and everyone else immediately starts the player. Therefore, the question of cheating does not bother me :) I need to send a signal to the rest of the players as quickly as possible, in total it turns out 1 function. But I also need it to be without the internet, because we may be in places where the internet connection is bad. Thank you for the proposed solutions, I will look at them and hope that something will suit my tasks.

[quote=“DarkDeivel”, post:7, topic: 901430]
The thing is, I’m a musician. I created a player in Unity that plays a metronome. Each musician has his own smartphone with headphones connected to it. I need one person to press the “PLAY” button and everyone else immediately starts the player. Therefore, the question of cheating does not bother me :slight_smile: I need to send a signal to the rest of the players as quickly as possible, in total it turns out 1 function. But I also need it to be without the internet, because we may be in places where the internet connection is bad. Thank you for the proposed solutions, I will look at them and hope that something will suit my tasks.
[/quote]
Are you trying to make it so each player gets the communication at the same time to equate fairness?

[quote=“Punfish”, post:8, topic: 901430]
Are you trying to make it so each player gets the communication at the same time to equate fairness?
[/quote]
As far as possible, I understand that this cannot be without delays, but it must be done as quickly as possible. I haven’t studied the links they gave me yet, I’m waiting for the weekend.

In PUN, you can send an event to all players (including the sender) via the server (RaiseEvent has the target "all" in it's options). Means: The Photon Server is sending this to everyone at the same time.
The issue is: When one player has loss or worse lag when the signal is sent, then this player will still be late.
You'd have the same with a dedicated server or direct connections, unless you sync the time between the players and everyone starts playing at a specific synced timestamp.

1 Like

[quote=“tobiass”, post:10, topic: 901430]
In PUN, you can send an event to all players (including the sender) via the server (RaiseEvent has the target “all” in it’s options). Means: The Photon Server is sending this to everyone at the same time.
The issue is: When one player has loss or worse lag when the signal is sent, then this player will still be late.
You’d have the same with a dedicated server or direct connections, unless you sync the time between the players and everyone starts playing at a specific synced timestamp.
[/quote]

Hello. The idea with a certain timestamp is cool and how did I not think of it before :sweat_smile:

P.S. As far as I knew, it seems that Photon Bolt can do without the Internet?

So you are trying to make it that all players get the message at the same time?

[quote=“DarkDeivel”, post:11, topic: 901430]
P.S. As far as I knew, it seems that Photon Bolt can do without the Internet?
[/quote]
Sorry to say but we don’t offer the LAN support anymore.

1 Like

[quote=“Punfish”, post:12, topic: 901430]
So you are trying to make it that all players get the message at the same time?
[/quote]
No, I’m not trying, a little delay is acceptable, but I liked tobiass’ idea of the timestamp. In theory, with such ideas, the delay is no longer so critical.

As a general rule when seeking help explain your desired outcome rather than asking help with a specific route to take. It's not uncommon that something can be done in an easier fashion but without knowing why/what you are ultimately after it's difficult to make suggestions.

So the topic title says how to make a super simple network, this meant that someone would suggest the simplest asset in which you don’t have to write a bunch of code for one function, secondly, in post number 7 I wrote a situation for which I need a network.

Well, without Internet is kind of the impossible, with the exception of LAN.

I do think Fish-Networking can cover your needs; it's very flexible and does also offer LAN support.

While I did read #7 I was not sure if your intentions were to have all OTHER players start at the same time, or the person pressing play + others to start at the same time. Either way, latency is going to be a factor no matter what.

To give you an example of how you might do this in FishNet though ...

private const double PLAYER_DELAY = 0.3d; //Maximum delay to wait for all players to get packet.

public void OnClick_Play()
{
   ObserversPlay(TimeManager.Tick);
}
private IEnumerator XYZ(double wait)
{
   yield return new WaitForSeconds(wait);
  PlayStuff();
}

[ObserversRpc]
private void ObserversPlay(uint tick)
{
    double timePassed = TimeManager.TimePassed(tick);
    double waitRemaining = Mathf.Max(0d, PLAYER_DELAY - timePassed);
    StartCoroutine(XYZ(waitRemaining));
}

You send the 'tick' which is aligned on all players. Using FishNet API 'TimePassed' you get the time it took to recv the packet. Then all players wait the remaining time of 'PLAYER_DELAY - timePassed'. They will all start at the same time, including host.

1 Like

[quote=“Punfish”, post:17, topic: 901430]
Well, without Internet is kind of the impossible, with the exception of LAN.

I do think Fish-Networking can cover your needs; it’s very flexible and does also offer LAN support.

While I did read #7 I was not sure if your intentions were to have all OTHER players start at the same time, or the person pressing play + others to start at the same time. Either way, latency is going to be a factor no matter what.

To give you an example of how you might do this in FishNet though …

private const double PLAYER_DELAY = 0.3d; //Maximum delay to wait for all players to get packet.

public void OnClick_Play()
{
   ObserversPlay(TimeManager.Tick);
}
private IEnumerator XYZ(double wait)
{
   yield return new WaitForSeconds(wait);
  PlayStuff();
}

[ObserversRpc]
private void ObserversPlay(uint tick)
{
    double timePassed = TimeManager.TimePassed(tick);
    double waitRemaining = Mathf.Max(0d, PLAYER_DELAY - timePassed);
    StartCoroutine(XYZ(waitRemaining));
}

You send the ‘tick’ which is aligned on all players. Using FishNet API ‘TimePassed’ you get the time it took to recv the packet. Then all players wait the remaining time of ‘PLAYER_DELAY - timePassed’. They will all start at the same time, including host.
[/quote]

Hello. This helped me, I really achieved the perfect synchronization for me in the tests. As for the LAN, that’s enough. I distributed a Wi-Fi access point with one phone, and connected with the other by specifying the Client Address IP of the main phone. Thank you.

2 Likes