Double-Fine-Game-Club / pongball

Pongball is a team based multiplayer game blending pong and pinball.
https://forums.doublefine.com/forum/80-pongball/
MIT License
11 stars 17 forks source link

Ball return on score breaks after returning to Main Menu #179

Open fragmental opened 7 years ago

fragmental commented 7 years ago

Ball return on score breaks after returning to Main Menu Just as the title says, if you return to main menu from the game, and start a new one, the ball will not return to its starting position when a goal is scored, essentially breaking the game.

fragmental commented 7 years ago

I don't think I'm familiar enough with theses systems to guess what is happening here or what has caused this. I will take a look any way and see if I can turn something up.

fragmental commented 7 years ago

Relevant error:

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEngine.GameObject.GetComponent[BoostPadForce] () (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/GameObjectBindings.gen.cs:38) SpinnerActivator.DeactivateBoost () (at Assets/scripts/entity/SpinnerActivator.cs:61) SpinnerActivator.OnLevelReset () (at Assets/scripts/entity/SpinnerActivator.cs:37) Score.OnTriggerEnterGoal1 () (at Assets/scripts/entity/Score.cs:199) Ball.OnTriggerEnter (UnityEngine.Collider Col) (at Assets/scripts/entity/Ball.cs:157)

Cheeseness commented 7 years ago

This only seems to happen if Speedster is the first map loaded. Is that in line with your experiences, @fragmental?

fragmental commented 7 years ago

Oh @Cheeseness haha. I think I must have opened speedster first every time, even though I did check other tables to see if the effect happened there.

You are correct. It only happens after exiting to the menu from the Speedster table. Speedster doesn't have to be opened first, but the error doesn't appear until after Speedster has been loaded, and then unloaded.

fragmental commented 7 years ago

180 and #181 seem to be completely unrelated from my testing, btw.

Edit: or at least, removing the extra copies didn't fix anything.

Cheeseness commented 7 years ago

I'm pretty certain it's just that the ObstacleNetworking component's registered things aren't getting cleared when returning to the menu (probably worth making sure nothing's registered on map load so that we can be guaranteed of a clean slate).

Best way to address this is to probably set all the delegates' values to null in a Start() function in ObstacleNetworking.cs, I suspect?

fragmental commented 7 years ago

Best way to address this is to probably set all the delegates' values to null in a Start() function in ObstacleNetworking.cs, I suspect?

I just tried this and it didn't seem to work.

ghost commented 7 years ago

we register some event hooks here that might need to be unregistered: https://github.com/Double-Fine-Game-Club/pongball/commit/01cb4599c69eacc00e4d44ec8b2d0dbb16e9cc38#diff-c15b1ff61f4d0af4af6f07c825e9a6edR20

And I also think I just spotted a bug here: https://github.com/Double-Fine-Game-Club/pongball/commit/01cb4599c69eacc00e4d44ec8b2d0dbb16e9cc38#diff-c15b1ff61f4d0af4af6f07c825e9a6edR32

That should be -=, not +=

Cheeseness commented 7 years ago

I just tried this and it didn't seem to work.

Ah, of course not. ObstacleNetworking is persisting between play sessions. The delegates just need to be cleared/unregistered like lightsoda said.

Reading up, I see recommendations to set delegates to null inside the relevant class (ObstacleNetworking). Exposing a function that does that which can be called just prior to instantiating the table would be the way to go.

Cheeseness commented 7 years ago

In the meantime, I've disabled the exit to menu button in the humble_release branch and will push out new builds to go up to Humble this afternoon (there's been some delay with getting Pongball stuff up, so maybe we can squeeze that quick fix in)

fragmental commented 7 years ago

And I also think I just spotted a bug here: 01cb459#diff-c15b1ff61f4d0af4af6f07c825e9a6edR32

That should be -=, not +=

I tried this, and it definitely did fix the scoring on exit to menu, but interestingly, it also completely removed the spinner when the scene was reloaded.

https://www.evernote.com/l/ATpEa53z_ZlKYqwIPlvOwfN3f9iU3vjWHdwB/image.png