Synchronize player and host movements

1

Hello. I'm doing a school project and I'm following the Unity Multiplayer Netorking tutorial. Everything worked properly, however the tutorial teaches you to have a player and a host, both each with a "character" that moves independently of the other. What I need to do is the "character" of each of them to have synchronized movements. For example if I move one of them to the side, I need the other player's character also to move to the side. Does anyone know how I can do this?

The tutorial I followed was: link

    
asked by anonymous 06.02.2018 / 11:15

1 answer

2

Hello,

I do not know how much of the tutorial you followed, but in this tutorial, what makes the characters have independent moves (each controls yours) is the verification in the character's move code.

if (!isLocalPlayer)
{
    return;
}

It checks if you are the localPlayer ie the controller of that character, and then "cancels" the script execution, if you are not.

So you end up controlling only your character. If you take that if from the drive code. When the host or player moves, the other will move as well.

I hope I have helped. Abcs

    
21.03.2018 / 22:48