Jump to content

Problem getting the Y axis value of my player when spawning on the network


JulienActiveMe

Recommended Posts

Hello, 

I am developping a multiplayer VR experience using unity, unity Netcode for game objects and LBE. 

When my client spawns on the network, the position (x and z) is correct. 

However, the Y axis value stays at 0 so I spawn on the ground.

For now, I have to set a value for this Y axis but I don't like it, because it does not fit all the player's height.  

The other client's avatar in the game seem to be positioned at the right height though. 

Is it a known issue ? 

 

SDK version 5.3.2

Unity version 2021.3.11

Netcode version 1.5.2

 

Thanks in advance ! 

Link to comment
Share on other sites

No. 

Actually, it doesn't make sense. 

When my first client spawn, I correct it's height. It's new height will now be shared with everyone. 

So when a second client spawns, the position of the first client seems allright, but I think that was due to correction I made when it spawned.

The variations are ok (When I duck or jump, the Y axis value is following my movement). 

 

 

 

Link to comment
Share on other sites

For pose, it should matter how you exchange data between players.

I did play abit with Unity Netcode, I can get correct HMD height.

54 minutes ago, JulienActiveMe said:

but I think that was due to correction I made when it spawned

You should check this part, maybe the correction has bug? 🙂

Link to comment
Share on other sites

No, correction =  I just set the height to a certain value (1.6) because I do not want it to be 0. 

So 

=> OnNetworkSpawn() since my Y = 0, I set it to 1.6

Once this position is set, I assume it will be shared to all the other clients that will connect from now on. 

But why is my height = 0 when I spawn ? X and Y are good, why not Y ?

In my PlayerPrefab, the parent game object's position is set to 0;0;0 as well as the playerCamera (child object containing the camera and TrackedPoseDriver). 

Link to comment
Share on other sites

For my scene, my player prefab did not have TrackedPoseDriver.

The only TrackedPoseDriver is attached to scene's camera itself.

For my player prefab for HMD,

I create a PlayerControl script, and in Update() function, I will get HMD pose and assign to transform.position and transform.rotation.

Link to comment
Share on other sites

image.thumb.png.493d3e3ab331491863a82639049e5775.png

public class PlayerControl : NetworkBehaviour
{
    public int speed;

    // Update is called once per frame
    void Update()
    {
        if (!IsOwner) return;

        var hmdPose = VRModule.GetCurrentDeviceState(0);
        if (!hmdPose.isPoseValid) return;

        transform.position = hmdPose.position;
        transform.rotation = hmdPose.rotation;
    }
}

By the way, I am using Vive Input Utility.

Let me know if you have further question. 🙂

Link to comment
Share on other sites

Okay, It's too late for me to change it all.
I'll think about leaving the camera out of the PlayerPrefab on V2 if needed. 

But I added the VIU, and tried to update my position using the HMD pose. 

Actually, I realized that just adding the VIU helped get the Y position, I do not need to update the position. 

Very strange to me, but this is now a closed case for me. 

 

Thank you very much for your help !!

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...