- Home /
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:
Answer by AtGfx · Jul 14, 2017 at 09:53 AM
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.
@AtGfx The ray method is working really well for me - thank you!
Two quick follow-up questions, however... :)
1) This now means that the avatar (I'm using Unity's Third Person Controller) rotates with the headset. For example, when I angle my head downward, the entire avatar leans forward. How do you recommend I fix that?
2) If I resolve that, I think the avatar will be properly co-located with my camera, but this means that I will see through some parts of the avatar. I would like to shift the avatar so that it is always positioned slightly behind the headset - close enough for the I$$anonymous$$ movement of my hands to look realistic, but far enough away so that I am not looking through the front of the third person controller's head! I have been able to position the avatar before, but it always floats at a certain distance in the world's reference frame, rather than at a certain distance behind the camera.
Oh sure, same problem with rotation...
$$anonymous$$aybe the best way to position your avatar is to remove it from the hierachy of the camera rig, and define a script on it with the camera eye as parameter. Then at each update you can position your avatar exactly as you want according to the camera parameter. You can set same translate in x,z and avoid y for example to position it, you can even rotate only the head of your avatar according to the camera rotation, etc.
For the hands, you can also define 2 avatars : if you are the simulated one, you display the hands, if you are not (so a remote one from multi) you display the ShaeAvater.
PS: if answer is ok for you, you can set it as accepted ;) thanks !
Again, super helpful - thanks so much! I would accept your answer, but I didn't post the original question... :(
Answer by emilyVR · Jul 14, 2017 at 09:44 AM
Did you ever figure this out? I would love to know the answer, too!
Hi, I didn't get the chance to try it myself yet... it looks like a good practice. Eventually I bought an asset called Instant VR edge, and using this asset going to change to my design avatar.
Answer by Eco-Editor · Jul 31, 2017 at 03:00 PM
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);
}
}
Hello,
I am trying to set the Vive headset position equal to my avatars leftEye position in Update. The script seems to work, as the Unity scene editor shows the camera correctly in the avatar's head. However, in the actual headset AND in the game view, the perspective is not from the eyes of the avatar. It is about 20 feet behind the avatar.
Any ideas what might be causing this, and how it can be fixed? I thought it might have something to do with the FOV, which seems like it cannot be changed.
Thanks