Host side have a bit of latency than Client side.
Options
in Photon Bolt
I have a problem , please help me to solve it.
Client side Movement is instantly , but the Host side has a little bit of latency , I don't Know the Reason , please tell me! Thank you!
this is the Movement Code
public override void SimulateController()
{
IOwnPlayerCommandInput input = OwnPlayerCommand.Create();
input.InputPos = tempPos;
input.InputRotateZ= gamepadDirection.x * -15;
input.Fire = Fire;
input.InputMousePos = MousePos;
entity.QueueInput(input);
}
public override void ExecuteCommand(Command command, bool resetState)
{
if(state.Dead)
{
return;
}
OwnPlayerCommand cmd = (OwnPlayerCommand)command;
if(resetState)
{
transform.position = ClampPos(cmd.Result.OutputPos);
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, cmd.Result.OutputRotateZ);
}
else
{
transform.position = ClampPos(cmd.Input.InputPos);
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, cmd.Input.InputRotateZ);
FireWeapon(cmd);
cmd.Result.OutputPos = ClampPos(cmd.Input.InputPos);
cmd.Result.OutputRotateZ = cmd.Input.InputRotateZ;
}
}
public Vector3 ClampPos(Vector3 CurrPos)
{
Vector3 tempPos = CurrPos; // get the struct for changes, can't do it directly.
// Limit the movement of the player within the bounds of moveArea
if (tempPos.x > moveArea.width)
tempPos.x = moveArea.width;
if (tempPos.x < moveArea.x)
tempPos.x = moveArea.x;
if (tempPos.y > moveArea.height)
tempPos.y = moveArea.height;
if (tempPos.y < moveArea.y)
tempPos.y = moveArea.y;
return tempPos;
}
Client side Movement is instantly , but the Host side has a little bit of latency , I don't Know the Reason , please tell me! Thank you!
this is the Movement Code
public override void SimulateController()
{
IOwnPlayerCommandInput input = OwnPlayerCommand.Create();
input.InputPos = tempPos;
input.InputRotateZ= gamepadDirection.x * -15;
input.Fire = Fire;
input.InputMousePos = MousePos;
entity.QueueInput(input);
}
public override void ExecuteCommand(Command command, bool resetState)
{
if(state.Dead)
{
return;
}
OwnPlayerCommand cmd = (OwnPlayerCommand)command;
if(resetState)
{
transform.position = ClampPos(cmd.Result.OutputPos);
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, cmd.Result.OutputRotateZ);
}
else
{
transform.position = ClampPos(cmd.Input.InputPos);
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, cmd.Input.InputRotateZ);
FireWeapon(cmd);
cmd.Result.OutputPos = ClampPos(cmd.Input.InputPos);
cmd.Result.OutputRotateZ = cmd.Input.InputRotateZ;
}
}
public Vector3 ClampPos(Vector3 CurrPos)
{
Vector3 tempPos = CurrPos; // get the struct for changes, can't do it directly.
// Limit the movement of the player within the bounds of moveArea
if (tempPos.x > moveArea.width)
tempPos.x = moveArea.width;
if (tempPos.x < moveArea.x)
tempPos.x = moveArea.x;
if (tempPos.y > moveArea.height)
tempPos.y = moveArea.height;
if (tempPos.y < moveArea.y)
tempPos.y = moveArea.y;
return tempPos;
}
0
Best Answer
-
What scene am I testing?5
Answers
-
Can you send us a project?0
-
Yeah,this is the project.You can download from there.stanchion said:Can you send us a project?
Link : https://pan.baidu.com/s/1i4DgFa9 Password: sdxu0 -
Do you have instructions to play and see the issue?0
-
the Unity Version is 5.6.1,First you need to host a Photon Server,stanchion said:Do you have instructions to play and see the issue?
and start loadbalancing server.
and set the Master server address is your photon server address, and package to Exe, then you can play.
0 -
the main problem is that in the client side move is instantly, but in the server side the movement has a little bit of latency, I just want to know why .stanchion said:Do you have instructions to play and see the issue?
0 -
What scene am I testing?5