- Home /
Multiplayer: Only see Players moving on Host
I have a simple multyplayer 2d Pong, but the problem is that I can only see the players moving on the host: On the Client, I can enter input for player movement, but i can not see him moving (left player). The server sees him moving. On the Server, i can enter input for the right player, also see him moving there. But the client sees nothing.
The client sees the players but they do not move in any direction. Here is the code for the player: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking;
[NetworkSettings(sendInterval = 0.1f)]
public class PlayerController : NetworkBehaviour
{
private GameManager m_Manager;
private Vector3 m_Move;
private const float m_MovementSpeed = 2.0f;
void Awake()
{
m_Manager = FindObjectOfType<GameManager>();
m_Move = Vector3.zero;
}
void Update()
{
if (m_Manager.m_GameStart)
{
if (isServer)
{
transform.Translate(m_Move * m_MovementSpeed * Time.deltaTime);
}
if (!isLocalPlayer)
{
return;
}
CmdMove(Input.GetAxis("Vertical"));
}
}
[Command]
private void CmdMove(float _axis)
{
m_Move = new Vector3(0, _axis, 0);
}
}
On the playerprefab attached is: - NetworkIdentity and Local Player Authority is enabled - - PlayerController Script (See above) - - -Network Transform: Everything is at default exept: Network Send Rate (29), Transform Sync Mode (Sync Transform) - - Rigidbody2d: Everything is at default exept: Collision Detection (Continous) - - BoxCollider2d
Thanks for helping
I think there is a problem with the isServer in the Update-Function. Because I also have a Ball in the game and it moved (but not synchron) until i put a isServer like here in the code.