Multiplayer camera problem

i am making a 3d car racing game online. everything is smooth and easy so far untill now i tried everything but didnt work .please give me suggestions



the camera of player one seems to be coming on player 2 screens too.
how can i get the camera 2 to work?

Why have you got 2 cameras? There’s only one camera in the game. So, instead of thinking of it as a game with player1 camera and player2 camera, think of it as the client camera, that’s for the player of that game instance.

I tried it I used only one camera which was camera 1 and I used it to stick on both cars but it still didn’t work . I’ll try it again just in case and send you screenshots

here you go


both are camera 1
4
camera 1 is sticked with both cars

i will now play as player 1

camera not following player 1
i will now play as player 2

camera is now moving but cant see player 2 car??

WHAT DOES THIS MEAN HELP!

Use only one camera and stick it on the player that the game is running for.

So say you and I were playing, and you’re player 1, the sedan, and I’m player 2, the 615. Then in your instance of the game, camera1 is stuck to the SedanSports object, and in my instance of the game camera1 is stuck to the _615 object.

Does that make sense?

yah i get it but then what do i have to do?
If player is sedan sports —> camera 1 stuck to sedan sports
If player is 615—> camera 1 stuck to 615
???
is that what you want me to do?

In a nutshell, yes. Check which player the game instance is running for and stick camera1 to their car.

how do i check that?
edit: debugger??

No, when you connect P2P. You need to have some mechanism in place to determine who the player is upon connection for each game instance.

ok but i tried debugger and found something interesting that the both cameras behaviour have the same car name

how am i supposed to do that??

I don’t know which object instance you’ve clicked on in that screen shot, so I cannot comment.

How many camera1 objects do you have in the scene (there should be only 1)?

What are the events that determine which player is running the game instance?

i have two camera1 on scene. one behind the car 1 and one behind car 2 did you not see the screenshots above?

i dont have any events like that can you send me screenshot of examples?

My earlier post:

Get out of the thought that you need a camera for each player. You need one camera for the game. Which car object it’s stuck to depends on which car is being driven in each instance of the game.


You only need 1 camera. It follows the car that the player controls in the game instance on their machine/device.

So, for example, I’m playing on my PC as player 2, and you on your PC as player 1. We both run our own copy/instance of the game. You run it as the sedan, me as 615.

In your instance of the game, camera1 (remember there is only 1 instance of it in the scene) is stuck to the SedanSports object.

In my instance of the game, camera1 (again, it’s the only instance of it in the scene) is stuck to the _615 object.

It’s the same camera1 in the GDevelop editor, but depending on who is playing the game, camera1 is stuck to different car objects. The camera in your game has no impact, bearing or affect on the camera in my game. We can use the same camera1 object. Because there are 2 games running, they don’t care about the other game’s camera.

When you connect the two games via P2P, one is the host and one the client. Make the host the SedanSports player, and the client the 615 player.


How are you connecting the two game instances?

I’m am not I’m using the multiplayer update


This is all the events I have
Am I missing smth?

Maybe I’m the one missing something. Your screen shots are of 2 game instances running at the same time. I assumed you were using multiplayer, like you have in the title of this thread.

So what are you trying to achieve? What do you mean by multiplayer - 2 games connecting P2P, or something else?

I just need the cameras to follow their players cars.i used the lobby system in the new gdevelop for the two players to connect.

Have you been through the wiki, read the section on Making multiplayer games with GDevelop and watched the tutorials? Particularly setting ownership and synchronising objects?

It looks like you’d have each player take ownership of a different car object and synchronise it, but not take ownership of the camera1 object or synchronise that. The camera1 object would be stuck to the car they’ve taken ownership of.