VR Multiplayer: Code Explained

Sdílet
Vložit
  • čas přidán 27. 08. 2024

Komentáře • 17

  • @AmanChaudhary-tb7ly
    @AmanChaudhary-tb7ly Před 4 měsíci

    Please continue next part on how to grab and how to client grab the object if any request state authority because i have a problem face in grabbing object

    • @immersiveinsiders
      @immersiveinsiders  Před 4 měsíci +1

      Add a "PointableUnityEventWrapper" component on the interactable and reference the "Grabbable" component
      Create a new script "RequestStateAuthorityForInteractionKinematic".
      using Fusion;
      using Oculus.Interaction;
      using UnityEngine;
      public class RequestStateAuthorityForInteractionKinematic : NetworkBehaviour
      {
      [SerializeField] private PointableUnityEventWrapper pointableUnityEventWrapper;
      [SerializeField] private bool GrabbedWhileSelected = false;
      [Networked]
      public bool IsGrabbed { get; set; }
      private bool prevValue;
      private void Start()
      {
      pointableUnityEventWrapper.WhenHover.AddListener(RequestAuthorityToInteract);
      pointableUnityEventWrapper.WhenSelect.AddListener(OnSelected);
      pointableUnityEventWrapper.WhenUnselect.AddListener(OnUnslected);
      }
      private void RequestAuthorityToInteract(PointerEvent arg0)
      {
      if (GrabbedWhileSelected)
      {
      Object.RequestStateAuthority();
      }
      else if (!Object.HasStateAuthority)
      {
      if (!IsGrabbed)
      Object.RequestStateAuthority();
      else
      Debug.Log("

    • @AmanChaudhary-tb7ly
      @AmanChaudhary-tb7ly Před 4 měsíci

      @@immersiveinsiders thanks brother

  • @61seyhan
    @61seyhan Před 9 měsíci

    Very helpful video

  • @taeyangyoo1941
    @taeyangyoo1941 Před 6 měsíci

    Hello, I tried this whole scrip and wathced previous video. But when I make a shared room, I can't change spawn point. Everytime spawn point is fixed by OVR rig camera's position. How can I fix it?

  • @gamedevelopersukanta414
    @gamedevelopersukanta414 Před 3 měsíci

    "RequestStateAuthorityForInteractionKinematic" where i attach this script and this script is allow to client grab function ?

    • @immersiveinsiders
      @immersiveinsiders  Před 3 měsíci

      You need to attach on the object you'd want to be grabbed across the network.

    • @gamedevelopersukanta414
      @gamedevelopersukanta414 Před 3 měsíci

      @@immersiveinsiders client is not able to grab object only host can grab but i want to client also grab the object

    • @immersiveinsiders
      @immersiveinsiders  Před 3 měsíci

      @@gamedevelopersukanta414 can you confirm that you are using shared topology? Same as this video?

    • @gamedevelopersukanta414
      @gamedevelopersukanta414 Před 3 měsíci

      @@immersiveinsiders yes I use shared topology same as video

    • @immersiveinsiders
      @immersiveinsiders  Před 3 měsíci

      @@gamedevelopersukanta414
      Add a "PointableUnityEventWrapper" component on the interactable and reference the "Grabbable" component
      Create a new script "RequestStateAuthorityForInteractionKinematic".
      using Fusion;
      using Oculus.Interaction;
      using UnityEngine;
      public class RequestStateAuthorityForInteractionKinematic : NetworkBehaviour
      {
      [SerializeField] private PointableUnityEventWrapper pointableUnityEventWrapper;
      [SerializeField] private bool GrabbedWhileSelected = false;
      [Networked]
      public bool IsGrabbed { get; set; }
      private bool prevValue;
      private void Start()
      {
      pointableUnityEventWrapper.WhenHover.AddListener(RequestAuthorityToInteract);
      pointableUnityEventWrapper.WhenSelect.AddListener(OnSelected);
      pointableUnityEventWrapper.WhenUnselect.AddListener(OnUnslected);
      }
      private void RequestAuthorityToInteract(PointerEvent arg0)
      {
      if (GrabbedWhileSelected)
      {
      Object.RequestStateAuthority();
      }
      else if (!Object.HasStateAuthority)
      {
      if (!IsGrabbed)
      Object.RequestStateAuthority();
      else
      Debug.Log("

  • @AndrewDeick
    @AndrewDeick Před 8 měsíci

    Good video!
    I don't understand what's happening at 5:11 though. It seems like commenting out that code would result in a different bug (resulting in 1 player one, 2 player twos, 3 player threes, etc). Can you explain it more?

    • @immersiveinsiders
      @immersiveinsiders  Před 8 měsíci

      If you don't have a condition in place to check if the player is joining is local to you or not, then every time a new player joins, the runner will duplicate the existing players.
      Let's say you joined 1st, the room will have just you, then when I join, the runner will spawn your player once again along with mine, so now the room will have two of you and one of me instead of just one of us each.

    • @AndrewDeick
      @AndrewDeick Před 8 měsíci

      ​ @immersiveinsiders
      Ok, maybe I have a misunderstanding of what is happening. I am assuming the parameter "PlayerRef" in the method OnPlayerJoined is a reference to the player who just joined (the player with the most recent join time)
      Assuming we remove the condition (player == runner.localPlayer):
      When Player 2 joins a room, I would assume that P1's callback fires, and P2's callback fires. This would result (incorrectly) in 2 Player2s, correct?
      To rephrase, the list of callbacks would be:
      OnPlayerJoined (player1) -- calledBy: player1-- (localPlayer == true)
      OnPlayerJoined (player2) -- calledBy: player1-- (localPlayer == false)
      OnPlayerJoined (player2) -- calledBy: player2-- (localPlayer == true)
      Now that I've typed this all out, I think I see where we're maybe getting confused. The 2nd line (which should be omitted) would spawn a Player1 prefab, but its Input Authority would be Player2, is that correct?

    • @immersiveinsiders
      @immersiveinsiders  Před 8 měsíci

      @@AndrewDeick Yes, you got that right!

  • @vvrr6dif
    @vvrr6dif Před 9 měsíci

    ❤❤❤❤🎉🎉🎉