I'm making a mobile game in which there are left/right/jump movement UI buttons. The players should be able to move with those buttons. I'm using Unity and Photon Fusion Host Mode.
The problem is, for the player in client, the movement is very weird. When I press the button, it moves 'a little bit' and then gets back to its original position.
Also, the host is controlling both, the host and client.
Since I'm getting input from the UI buttons, I've not used INetworkInput, OnInput, TryGetPlayerInput or anything else.
I'm just checking this in BeforeUpdate.
public void BeforeUpdate()
{
if(Runner.LocalPlayer == Object.InputAuthority)
{
isLocalPlayer = true;
}
}
And doing the movement in FixedUpdateNetwork
public override void FixedUpdateNetwork()
{
if(isLocalPlayer)
{
if(moveRight)
{
rb.velocity = new Vector2(3,rb.velocity.y);
}
if(moveLeft)
{
rb.velocity = new Vector2(-3,rb.velocity.y);
}
}
}
How to do player movement using UI buttons using Photon Fusion Host mode?
One more thing, the movement works well when I do the same thing in Shared Mode.