How does Fusion Tanknarok tanks have an InputController that takes input?

Options
Flaemnova
Flaemnova
edited July 2022 in Fusion

Hello,

I'm new to Photon Fusion, and have been reviewing the sample code from Fusion Tanknarok from Hello fusion. There, there are two seperate scripts, FusionLauncher.cs and InputController.cs.

From what I understand, the networkRunner is running FusionLauncher.cs, spawning the player and world etc. How does the inputController.cs on the tank preFab work with no networkRunner?

Specifically, I'm trying out my own implementation of a shooter, and have been using onInput() method from the Launcher to control my character. I want to create a InputController script and use the onInput() method there. (It's a multiplayer shooter, I believed this would help seperate the controls)

Best Answer

  • Isaac_Augusto
    Answer ✓
    Options

    Hi,

    The inputControlle.cs is able use the OnInput() method because it implements the INetworkRunnerCallbacks interface and register itself as callback to the runner on Spawned() Method:

    public override void Spawned()
    {
       //...
       {
          Runner.AddCallbacks(this);
       }
       //...
    }
    

    It's needed to implement the interface and are on the same object as the NetworkRunner or explicit register as callback to receive them from the Runner.

    -----

    Isaac Augusto

    Photon Fusion Team

Answers

  • Isaac_Augusto
    Answer ✓
    Options

    Hi,

    The inputControlle.cs is able use the OnInput() method because it implements the INetworkRunnerCallbacks interface and register itself as callback to the runner on Spawned() Method:

    public override void Spawned()
    {
       //...
       {
          Runner.AddCallbacks(this);
       }
       //...
    }
    

    It's needed to implement the interface and are on the same object as the NetworkRunner or explicit register as callback to receive them from the Runner.

    -----

    Isaac Augusto

    Photon Fusion Team

This discussion has been closed.