1
\$\begingroup\$

My apologies in advance for the vague question, since I don't understand the problem well enough to ask in finer detail.

I want to create a multi-player Unity application using the Oculus SDK. Let's say there are two players in the scene, A and B. The problem is this: When player A presses a button using his index finger, the hand avatar for player B also displays a moving index finger. In short, hand movements for one player are also observed for the other. Controller inputs are also read without any ability to distinguish whether they originate from player A or B.

What are the possible approaches for eliminating this problem, if it is mandatory that I continue using Oculus SDK?

\$\endgroup\$
  • 1
    \$\begingroup\$ How are you detecting and responding to player input currently? Show us your code and relevant editor setup so we can reproduce the same issue you're seeing and test candidate solutions to be sure they work. \$\endgroup\$ – DMGregory Jul 30 at 14:10
0
\$\begingroup\$

I think the Illusion of multiplayer can be confusing sometimes. In the background there is only one input to feed and that is the 'localPlayer' clients, so all you really need to do is check

if(!isLocalPlayer)return; right above where you feed the input to just exit out of sending it.

Or you can wrap the input method in a if(isLocalPlayer) That way only the correct player feeds that input to the server.

Then the server will sync up all the clients actions so they still get to use input also it's just coming from their own client.

a simple example

void Update () {
    if (!isLocalPlayer) return;
    var h = Input.GetAxis("Horizontal");
    var v = Input.GetAxis("Vertical");
    TranslateMove(h,v);
}
void TranslateMove(float h, float v)
{
    transform.Translate(new Vector3(h, 0, 0) * 3 * Time.deltaTime);
    transform.Translate(new Vector3(0, 0, v) * 3 * Time.deltaTime);
}

above only the localPlayer can control the input otherwise it will exit out. the server handles syncing up the rest of the clients inputs and movements.

note : you would also want to check if(isLocalPlayer) on anything that handles remote actions or things like handling damage(if you get damaged you don't want every client to receive it), basically anything that only the localplayer should be considered.

\$\endgroup\$
  • 1
    \$\begingroup\$ Searching around for local multiplayer on the Oculus Rift, i found what looks like a very informative post. This may shed some light. reddit.com/r/OculusQuest/comments/bf1e3g/… \$\endgroup\$ – Jody Sowald Jul 30 at 16:04
  • 1
    \$\begingroup\$ Were you using something other than Unity's Multiplayer? you can run Local games also that way you are using same logic whether your local multi-play or a part of something else like a cloudhost ect. \$\endgroup\$ – Justin Markwell Jul 30 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.