Synchronize player and host movements

Asked

Viewed 48 times

0

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

The tutorial I followed to do is this: https://unity3d.com/pt/learn/tutorials/s/multiplayer-networking

1 answer

1

Hello,

I don’t know how much of the tutorial you followed, but in this tutorial, what makes the characters have independent movements (each one controls yours) is the verification in the character’s movement code.

if (!isLocalPlayer)
{
    return;
}

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

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

I hope I helped. Abçs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.