(SOLVED) Online Multiplayer Smooth Camera Bug

Robo Janitor

A bug I guess: If all the players get into the session from the start, 80% of the times each one has their own correct smooth camera, but if a player joins in the middle of the session the host always starts to get his camera ‘fighting’ with the camera of the player that just joined.

On top of this I made the username show the PlayerID and as you can see in the host window it shows both players as 1 but in the player 2 window it shows both players as 2.

Control wise each play character is correctly being controlled by the correct player.

Been trying to solve this for weeks now and can’t figure it out, any help is appreciated! :slight_smile: Thanks in advance!

What is supposed to happen:

What happens:

Code:

Video Recording of the problem: https://www.youtube.com/watch?v=TioJ6i0kgLE

Up. If anyone can please help me, still struggling with this

A few nitpicking things first - please don’t have an “At the beginning of the scene” as a condition of a “Repeat for each instance of Player” loop. Have a beginning of scene event, and make the repeat a subevent off that. Otherwise the repeat is processed every single game frame.

That last event can be done a lot differently. Use the sticker extension & behaviour, set the USERNAME.text once in a beginning of scene event block and stick it to the player.

There is no need for a trigger once if the event (or parent event) is has the “At the beginning of the scene” condition. By definition the beginning of scene only happens once.

And consider refactoring the first block of events (all those before the “USERNAME” Event Group) to:

That may solve your issue.

1 Like

Thanks very much :smiley: Going to try it on Monday. Hopefully it solves it

Didn’t work :confused: Now both the players have their camera fighting each other. Tried some variations of your code as well and still can’t figure this out

Could you screen snip your current events?


Here you go.

I’m wondering if deactivating the smooth camera when a new player joins might be a problem. What if you take out the second to last event:

Same thing happens, no difference at all. Both cameras keep fighting

That SmoothCamera behaviour is a right pain in the proverbial. It’ll synch across all players if they all join the lobby at the start.

But as soon as a player joins later, it screws up. And I’ve tried all manner of combinations to get it working, but it’s just refusing.

So I’ve come up with the following solution that works for late joiners. Although it doesn’t use the SmoothCamera behaviour, it implements a smooth moving camera with one event and 2 actions:

If you implement this, remember to remove the SmoothCamera behaviour from the player ojects.

2 Likes

Thanks so much! Far away from the computer at this moment but will be testing it out tomorrow first thing

It worked!!! You’re a life saver! I’ll be sure to credit you in the game!

Actually this only works on pc, on mobile (Android) the camera goes crazy and I think it goes very far. Doesn’t even show the player or map

Nevemind, my mistake! I put a number in a very wrong place and had my head scratching for many days