Anyone working host migrating Photon Fusion advance asteroids in Unity 2022.2.1f1?

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.

Anyone working host migrating Photon Fusion advance asteroids in Unity 2022.2.1f1?

HorangPark
2023-01-03 14:33:05

Hello!

I'm trying to do running Photon's official Fusion Unity sample game called Advance asteroids.

Everything working on Unity 2022.2.1f1 and build too.

but I was running host on "build file (like an exe file)", and running client version on "editor".

and I did quit host, editor(client) show many error log in each frame.

I think, the reason was GameStateController is not restored(spawn). also releasing log says "isSceneObject: true".

am I need to remove GameStateController GameObject in scene and try to spawning GameStateController? or did testing wrong or need to fix configurations?

Thank you.

Comments

HorangPark
2023-01-04 03:11:36

I did 2020.3.35f1, It's not working too.

PoPo4860
2023-01-04 09:02:32

I've been through the same situation as you, and at I think a little code modification has made it work.

I hope my experience is helpful.

That's the first problem.

GameStateController will not be recreated.

In the process of Host Migration, runner.GetResumeSnapshotNetworkObjects()

The deleted GameState Controller is not loaded.

I don't know exactly why, but it seems that only objects created by Runner.Spawn() are imported.

My solution.

AsteroidsGame.cs

[SerializeField] private GameStateController _gameStateController;

public void OnSceneLoadDone(NetworkRunner runner)

{

runner.Spawn(_gameStateController, Vector3.zero, Quaternion.identity, PlayerRef.None);

}

This is the second problem number two.

Bullets have not been generated, but there are times when an update is attempted.

My solution.

SimpleObjectCollection.cs

public void SimpleFixedUpdateNetwork(NetworkRunner runner, NetworkBehaviour owner)

{

for (int i = 0; i < _states.Length; i++)

{

	T state = _states[i];

	if (state.IsAlive **&& null != _gameObjects[i]**)

	{

		state.SimpleFixedUpdateNetwork(runner, owner.Object, _gameObjects[i]);

		_states[i] = state;

	}

}

}

Here's the third problem.

The Spaceship Controller has not found the _gameStateCtrl since migration.

I didn't know the exact reason, but I found the moment when I lost the _gameStateCtrl and put it back in.

My solution.

SpaceshipController.cs

public override void Migrated()

{

base.Migrated();

**_gameStateCtrl = GameStateController.FindInstance(Runner);**

**Runner.AddCallbacks(this);**

GameStateCtrl.UpdatePlayer(Object.InputAuthority, this);

}

public override void Despawned(NetworkRunner runner, bool hasState)

{

_bullets.Clear();

**_gameStateCtrl = GameStateController.FindInstance(Runner);**

_gameStateCtrl .UpdatePlayer(Object.InputAuthority, null);

}

Here's the fourth problem.

There has been a phenomenon in which the score data could not be imported since the migration.

My solution.

MigrationManager.cs

var newNO = runner.Spawn(resumeNO, p,q, PlayerRef.None, (networkRunner, o) =>

{

o.CopyStateFrom(resumeNO);

if(o.TryGetComponent(out var spaceshipController))

{

spaceshipController.CopyStateFrom(resumeNO.GetComponent());

}

newMigrator = o.GetComponent<MigrationBehaviour>();

newMigrator.IsPendingMigration = true;

newMigrator.IsMigrated = true;

});

HorangPark
2023-01-04 09:08:15

Wow! thank you so much!

Back to top