Driving a Vehicle

Options
Hello Everybody :)

I'm trying to make a Player move around and sync that and that works perfectly fine

but the player also can drive Vehicles....the Vehicle has a Script for Control so when the Player gets closer to the Vehicle and Presses the Key his Player Component Script gets Disabled and Enables the Vehicle Controller Script and Vice Versa

but the problem when connecting It's working fine for the master player (who connected first and created the room)

but Its very Laggy for the other Player (that is not the master) and whenever he tries to move with the vehicle
the vehicle gets back to It's starting Position very quickly and never moves

the Vehicle and Player both has Photon View and Transform Photon View Components

How to Fix this Please

thank you so much for Supporting

Comments

  • Hi @Imperial,

    [...] whenever he tries to move with the vehicle the vehicle gets back to It's starting Position very quickly and never moves


    This sounds like the car is still controlled by the MasterClient - I guess you are instantiating the cars either by using PhotonNetwork.InstantiateSceneObject or placing it inside the editor, am I right? Using one of these ways the objects will be handled basically the same by PUN which means that they are controlled by the MasterClient. This furthermore means that any other client is not able to update the object's position for example which explains the above described problem. So in order to get things working the client who wants to use the car have to request the Ownership of it. I recommend you taking a look at the Transfer Ownership Demo which comes with the PUN package and also taking a look at the related documentation page.