Trouble with Fusion Tutorial 102

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Fusion.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Trouble with Fusion Tutorial 102: does not implement interface

MuKapp
2022-05-28 23:15:52

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
2022-05-30 00:04:47

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

Back to top