Custom avatar on HTC Vive CameraRig

Hello all

I’m trying to dress the cameraRig with avatar body for a multi user simulation.
All the relevant scripts are on the cameraEye component, as the user is walking in the room.
When I place the avatar on the eye component I receive a “flying in the air” character. How can I “ground” my avatar and still be able to have it follow the users body?

picture for how the hierarchy is now:
96965-shaiavatarmodel.jpg

Hi !

Your problem comes from SteamVR that offset your camera from the ground dsitance.

When you define a CameraRig, you place it on the ground, then the camera is offset by the ground distance that is tracked by the Vive. If you place a ShaeAvatarModel in the Camera eye, it will also take this offset and fly in the air. A solution can be to constantly invert this offset : you put a script in camera eye and reference the avatar, then at each update you modify the position of the avatar according to the position of the camera. Another solution can be to set a script on the avatar that constantly shoot a ray under it to get the distance from the ground, and you have just to offset it corresponding to the distance value.

Did you ever figure this out? I would love to know the answer, too!

Another thing that is related to this query is adding idle and walking animations to the multiplayer avatar. When the person, cameraEye is moving, than the transform.position is changing. If the position change of x,z axis is bigger than 0.2 than play walk animation. If position doesn’t change for a frame play idle animation.

I’ve tried something like that, it’s not currently working:

    private void Update()
    {
        gameObject.transform.position = new Vector3(cameraEyes.position.x, 0, cameraEyes.position.z);
        gameObject.transform.rotation = Quaternion.Lerp(gameObject.transform.rotation, cameraEyes.rotation, 5 * Time.deltaTime);

        Vector3 currentPosition = transform.position;

        if (currentPosition.x > 0.2 || currentPosition.x < 0.2 && currentPosition.z > 0.2 || currentPosition.z < 0.2) 
        {
            playerAnimator.SetBool("Walk", true);
            lastPosition = currentPosition;
        }
        else
        {
            playerAnimator.SetBool("Walk", false);
        }

    }