Trouble with Fusion Tutorial 102: does not implement interface

Options
MuKapp
MuKapp
edited June 2022 in Fusion

I'm learning Fusion but having trouble with Tutorial part 102, which creates a basic multiplayer spawner. I added the code as written but I've been running into some unexpected errors. The code is pasted below:

using Fusion; // I added this, although it was not listed in the tutorial

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using System;


public class BasicSpawner : MonoBehaviour, INetworkRunnerCallbacks

{

public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) { }

public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { }

public void OnInput(NetworkRunner runner, NetworkInput input) { }

public void OnInputMissing(NetworkRunner runner, PlayerRef player, NetworkInput input) { }

public void OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason) { }

public void OnConnectedToServer(NetworkRunner runner) { }

public void OnDisconnectedFromServer(NetworkRunner runner) { }

public void OnConnectRequest(NetworkRunner runner, NetworkRunnerCallbackArgs.ConnectRequest request, byte[] token) { }

public void OnConnectFailed(NetworkRunner runner, NetAddress remoteAddress, NetConnectFailedReason reason) { }

public void OnUserSimulationMessage(NetworkRunner runner, SimulationMessagePtr message) { }

public void OnSessionListUpdated(NetworkRunner runner, List<SessionInfo> sessionList) { }

public void OnCustomAuthenticationResponse(NetworkRunner runner, Dictionary<string, object> data) { }

public void OnHostMigration(NetworkRunner runner, HostMigrationToken hostMigrationToken) { }

public void OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment<byte> data) { }

public void OnSceneLoadDone(NetworkRunner runner) { }

public void OnSceneLoadStart(NetworkRunner runner) { }


async void StartGame(GameMode mode)

{

// Create the Fusion runner and let it know that we will be providing user input

_runner = gameObject.AddComponent<NetworkRunner>();

_runner.ProvideInput = true;


// Start or join (depends on gamemode) a session with a specific name

await _runner.StartGame(new StartGameArgs()

{

GameMode = mode,

SessionName = "TestRoom",

Scene = SceneManager.GetActiveScene().buildIndex,

SceneObjectProvider = gameObject.AddComponent<NetworkSceneManagerDefault>()

});}


private NetworkRunner _runner;


private void OnGUI()

{

if (_runner == null)

{

if (GUI.Button(new Rect(0,0,200,40), "Host"))

{

StartGame(GameMode.Host);

}

if (GUI.Button(new Rect(0,40,200,40), "Join"))

{

StartGame(GameMode.Client);

}

}

}

}



The errors that I received on this were the following:


Assets/BasicSpawner.cs(17,55): error CS0246: The type or namespace name 'NetAddress' could not be found (are you missing a using directive or an assembly reference?)


Assets/BasicSpawner.cs(17,81): error CS0246: The type or namespace name 'NetConnectFailedReason' could not be found (are you missing a using directive or an assembly reference?)


Assets/BasicSpawner.cs(7,44): error CS0535: 'BasicSpawner' does not implement interface member 'INetworkRunnerCallbacks.OnConnectFailed(NetworkRunner, NetAddress, NetConnectFailedReason)'



Could anyone please help me figure out what's happening? I tried reinstalling the latest stable version of Fusion. I'm using Unity version 2021.3.2f1 on MacOS M1

Comments

  • MuKapp
    Options

    Please ignore-- I referred to the downloadable example code. The error was that I missed some necessary "using" statements.

This discussion has been closed.