I have a NetworkManager that creates an object on game start as below. This works for the client and host.
puck = Instantiate(spawnPrefabs.Find(prefab => prefab.name == "Puck"));
NetworkServer.Spawn(puck);
The manager also creates the players, each an objects that create objects on player clicks. Players are also created seemingly without issue. I’ve tried changed this all sorts of ways, but always get variations of the same issue. In the player object, I try creating a new object on click via this:
....
if (isLocalPlayer)
{
Vector2 mousePosition = m_Camera.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
m_currentSwipe = Instantiate(swipePrefab, Vector2.zero, Quaternion.identity);
m_swipeList.Add(m_currentSwipe);
Cmd_CreateNewSwipe();
}
....
[Command]
private void Cmd_CreateNewSwipe()
{
NetworkServer.Spawn(m_currentSwipe);
}
This works locally, but isn’t creating the object for clients. I feel like I just don’t understand where replication is supposed to take place, even after looking at other examples and other questions.
Any tips would be greatly appreciated. I feel like once I get this one thing down, I’ll better understand mirror, in general.