Our team is developing a football game. But we are stuck in a step.
We can't move forward because of this.
When we make client side prediction, the local player plays on the current time.
But the other objects like balls and other players play in the past(due to latency).
Normally for other objects we use interpolation but this doesn't work for the ball because local player interact with it while moving and it causes the other players to intertwine with the ball.
We tried to take the ball to the current state simulating physics and run all work-flow on the local. But this time when other players interact with the ball, they seems like moving the ball from far behind. Because of the other players in the past.
What is the best method to use for this situation?
Related
I am using Netcode for a simple 1 vs. 1 football game.
Players and the ball have frame skip problem even in a simple local network.
I added the "ClientNetworkTransform" component to sync the positions of the players and the ball and even wrote a simple position sync component by myself, but both have the same frame skip problem.
by the way, I don't want to use interpolation because players and the ball slide while they move.
Here is the recorded video:
This is a Host-Client method. It also has this problem when I use the Server-Client method.
https://www.youtube.com/watch?v=HDWkdlzdNeQ
What is your suggestion?
I am making Network game using Unity. I want to configure my network using PUN2. In particular, I notice that I can synchronize several basic variables through the OnPhotonSerializeView () method. However, this does not include custom classes such as GameObject and Transform. So what should I do to synchronize the Target Transform in that inspector view?
There are a few ways to tackle this. It depends on what you need this target for, and if it makes since for the object to exist on the other clients if it's not being targeted by any object.
Suppose you have Player that is synced, and a blue ball and a red ball in the scene.
The player has a ball that they are "holding". You want to trigger a synchronization so on all clients, if the player is holding a red ball it will hold it for all clients, and if they hold the blue ball it will do so for all clients.
The problem linking the blue ball in one client to all the blue balls in everyone else's client.
Option a) Give each ball a name and have some static dictionary mapping their name to the object in the scene (you can make them add themselves on the Awake or Start of the ball). Now you can synchronize the name of the ball that a player holds (a string in oppose to an object). When a client gets the name change, you can handle the name change as looking it up in the static dictionary, and setting it as the ball being held.
Option b) Synchronize the player AND the balls. Anything logic-related will only happen for the current player. So if the local player holds a ball, the player position will be synced and the ball position will be synced but nothing else will happen for the other players. This of course assumes this works for whatever you are trying to accomplish.
Option c) Serialize the ball. Send the data which describes the ball (size, color, etc) and create a new instance on the client side. This will NOT be tied to any existing balls on the client side. You may need check and destroy whichever ball is already being held. This is probably the least effective way to accomplish this, performance-wise.
My question is simple.
Im creating top down 2D shooter game via PUN2 Free in Unity.
I want to synchronize collisions through network, to avoid lags inaccuracy.
A player is firing a bullet and it hits enemy. I want players to know about all bullets hits(to reduce health, get kill, etc.).
Should I call RPC_Hit() from shooter to other players to inform about actual hit or it would be more wise to call RPC_Hit() from hurt player to other players in game.
Im asking in terms of better synchronization, I guess lags will happen, so in my oppinion it would be better to call RPC function from player which got hit, but then if I would need to send callback only to shooter(for example, to let him now how many dmg he did) it would be hard, cause I can only send RPC to "MasterClient,All,Others".
This bothers me.
I can not find any informations about this.
In same moment the Player1 and Player2 view differs cause of Lag
I am making a 1v1 multiplayer game such as 8 ball pool using unity. The overview of the approach I am using currently is:
1) Sync positions of each ball on both players.
2) If it's player1's turn: Get vector3 force applied on white ball and run the physics on
3) Send force from player1 on white ball and run it on player2.
4) Change turn once all balls are static or pocketed.
Problem is that even though: White ball's initial position and force applied are same for both players. The end positions of all balls are not the same. There is randomness in the physics I guess. The balls move and behave differently especially after collisions. There is sort of a butterfly effect and the end result of positions of balls on table is different for both players.
My question is that how will you approach in making a 1v1 8 ball pool where there are lot of objects and physics going around and ensure that everything happens the same way for both players.
Physics need to happen on a single instance of your app then propagated to others from there. Otherwise said, one player should be server + client and other players should be clients. All physics happen on server and clients send their commands to it like force applied on white ball, direction, etc.
Unity HLAPI for networking : https://docs.unity3d.com/Manual/UNetUsingHLAPI.html
Ok, so I'm trying to implement networking for a school project. (Part of my team's final project)
It's supposed to operate on a turn-based system. IE, when a player is done, they hit "next turn" and they lose control, while the other player gains control.
So, to test my networking and get the basics going, I've made a little program that spawns a cube whenever a server is joined or created (so one cube for each player), and each player is able to move only their own cube.
So far, I can have the cubes moving around and their transforms are perfectly synced up on both instances of the game simultaneously, and each player can only control their own cube.
However, when I click "Next turn", the turn only changes on ONE of the instances.
According to this, it SHOULD be watching the turn change:
And this is my turncontrol code (It's a little sloppy for now until I find a hardcore way to set the code's player number depending on whether they're the host or client)
How the heck do I make sure that when I click "Next Turn", the turn changes in both instances, and how do I make sure that the cube's player number is dependent on whether they're the host or client?
That and I have the very strong suspicion that the assignment of a player's "player number" (IE, whether they're player 1 or 2) is being assigned locally (Not reflected across instances) as well, since each player can only move when the turn is set to 1 (Meaning that when both players spawn, they're both set to be player 1. :s)
Any assistance would be appreciated. Networking is completely new to me and I'm wigging out trying to wrap my head around it.