cancel
Showing results for 
Search instead for 
Did you mean: 

Making a character head move according to the Oculus.

TrollAxeThrower
Explorer
We are creating an interactive experience (some might even call it a game). We have an avatar for the player - a Dog - with bones and animations. We want the player to be able to look at his own avatar from the avatar's point of view (eyes/head), and make him realize that he is a dog (or at least that he is looking through the eyes of a dog.) so we placed the camera in front of the dog’s head. The issue is when the player turns around (180 degrees), he sees the inside his own body, instead of just the outside, and some of the texture gets cut out, and that just ruins the experience we are trying to deliver.
The best solution in my opinion is making the head rotate and move according to the camera, and the entire body move according to the position and rotation of the head using Inverse Kinematics. (using the bones in the process) I saw a solution that does that successfully: https://www.youtube.com/watch?v=xJSMQutHtIQ but on this example he uses a mecanim character. So I don’t really know if I can use it in my case.
An optional solution is to make the Oculus determine the orientation of the head, and the position of the camera will be in front of his face, effectively determining the position of the camera, and making it “Orbit” around the head. In addition we can try and limit some of the weird movements a user can do with the Oculus by moving the dog on extreme unrealistic movement. (like making the dog turn when a player turns his head more than 150 degrees on each direction) Orienting the head must be done according to the bones.

Thanks!
7 REPLIES 7

Marbas
Honored Guest
I needed something similar for my game project. The problem is that the head-bone axis may not be aligned properly with the ovr tracker/camera object, which in my case resulted in completely wrong rotations.

Attach the script to the dog's head-bone.
You may have to experiment changing the euler axis values around (update/hack part) for your model to be properly aligned.


using UnityEngine;
using System.Collections;

public class AlignToTracker : MonoBehaviour {

public Transform hmdOrientation; // In the inspector add the "OVRCameraRig/CenterEyeAnchor"

private Vector3 tempRot;

// Update is called once per frame
void Update () {

// Hack to align avatar head-bone to tracker orientation
tempRot.x = -hmdOrientation.localEulerAngles.y;
tempRot.y = hmdOrientation.localEulerAngles.z;
tempRot.z = -hmdOrientation.localEulerAngles.x;

// Update head rotation
transform.localEulerAngles = tempRot;

}

}


Hope it helps!

serrarens
Honored Guest
You might want to take a look how I solved this in my InstantVR Free asset. It is for a humanoid avatar, but I think you should be able to translate that to the dogs head. You can retrieve it for free from the asset store: https://publisher.assetstore.unity3d.com/package.html?id=89965

Marbas
Honored Guest
"serrarens" wrote:
You might want to take a look how I solved this in my InstantVR Free asset. It is for a humanoid avatar, but I think you should be able to translate that to the dogs head. You can retrieve it for free from the asset store: https://publisher.assetstore.unity3d.com/package.html?id=89965


Wrong link.
https://www.assetstore.unity3d.com/en/#!/content/23011

serrarens
Honored Guest
Thank you for correcting the URL! (it was definitely bed-time by then...)

TrollAxeThrower
Explorer
Thanks everyone! 😄 Eventually we added some head animations to the head and used blend trees to get the head to the rotation we wanted. Sorry I didn't reply back soon.

Hi,

I was looking for a solution to the same question you had. Could you explain what animations you added to the head and did the head rotate according to the headset. So when you rotated your head could you look at the environment in unity that is on the right?Instead of the whole environment moving with the head movement. 

 

I hope I made sense. 

 

Thank you in advance