collapse

Welcome to VRTITTIES

A place for VR Porn Games, Oculus Rift Porn Games, Vive Porn Games, VR Porn Game Downloads & VR Sex Games.

Please feel free to discuss anything about Oculus Rift Porn Games, Vive Porn Games and VR Porn Games.

The answer to the anti spam question is facebook. If you have any issues registering then flick me an email or post as a guest. If you make an account you do not have to answer any anti spam questions after 10 posts.

You will need to sign up to the forum and make a number of posts before you can post links to other websites.

If you are ever looking at buying some VR Porn please use my affiliate links on the right sidebar.

Thanks,

VRTITTIES, New Zealand

Chelsearift@gmail.com


Author Topic: Tutorial - Dynamic Head Tracking in Unity3D  (Read 27529 times)

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Tutorial - Dynamic Head Tracking in Unity3D
« on: November 30, 2014, 02:49:44 PM »
While I was working on UE4 head tracking, I did some research to see how it can be done in Unity3D - here's what I found.

Grab the HeadLookController script and add it to your project: http://wiki.unity3d.com/index.php?title=HeadLookController
Drag it onto the root of a character in your scene, and then set it up using something similar to the settings described here: http://blogs.unity3d.com/2009/07/10/just-looking-around/
You'll need to open up your model's skeleton hierarchy and drag the appropriate bone names into the slots.
Drag your character's Root bone into the Root Node field.
Give the Segments block a size of 2 if you want your model to turn her torso along with her head, and include the bones where you'd like the torso turn to start and end.
If you just want her to turn her head, set Segments size to 1 and just include the Neck and Head bones.
Set Override Animation to true.

Try running it, and you should see your model staring at the center of the world. Once you've got that working, we can move onto the next bit, which is getting her looking at you.
« Last Edit: December 01, 2014, 06:45:10 PM by Syncret »

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #1 on: November 30, 2014, 03:00:13 PM »
Hopefully by this part, you've gotten the right bones in the right slots, and your character is staring at the world origin.
For the next bit, we need to make a minor modification to the script.

The supplied HeadLookController behavior specifies a specific vector to look at. We want to replace that with an object in our scene.

Comment out the line on or around line 35 that reads "public Vector3 target = Vector3.zero;"
Add a new line to replace it that reads "public GameObject targetObject = null;", like so:
Code: [Select]
//public Vector3 target = Vector3.zero;
public GameObject targetObject = null;
Now, somewhere close to line 100, you'll see where the script was using the Vector3 target variable. We'll comment that out and replace it with the location of our supplied object, like this:
Code: [Select]
// Desired look direction in world space
// Vector3 lookDirWorld = (target - segment.lastTransform.position).normalized;
Vector3 lookDirWorld = (targetObject.transform.localPosition - segment.lastTransform.position).normalized;
Now the lookDirWorld variable will be pointing at the location of whatever target object we supply.

Save the script and back in your scene, you should now see that the Target vector variable is gone from the script properties, and an object variable is in its place.

Find your OVRPlayerController object and drag it into this object reference.

Run your scene, and your character should be looking at the camera now.

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #2 on: November 30, 2014, 03:37:55 PM »
Updated HotelPlay with head tracking enabled: https://www.mediafire.com/?63bcf5eu0qlu3cx

Mirai is using a 2-segment chain (Torso->Torso2), (Neck->Head), so she twists her body a bit to look at you.
Haku and the girl against the wall are using 1-segment chains - just neck and head.

PornulusRift

  • VR Porn Fiend
  • ***
  • Posts: 91
    • PornulusRift
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #3 on: November 30, 2014, 04:52:32 PM »
Wow, thanks!  Definitely going to try this out.

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #4 on: November 30, 2014, 05:32:54 PM »
:) Your work was what first inspired me to play around with this stuff. Happy to give something back!

PornulusRift

  • VR Porn Fiend
  • ***
  • Posts: 91
    • PornulusRift
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #5 on: November 30, 2014, 07:22:43 PM »
I got it working, but its looking at the player object position, not the camera position.  So when you move you head around the positional tracking has no effect on where the model is looking.

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #6 on: November 30, 2014, 09:03:43 PM »
Hmm. Might need to grab the CenterEyeActor as a secondary object and add its transform to the OVRPlayerController's transform (The camera's transform is relative to the player controller) - or there may be a way to get its worldspace transform directly. Feel free to give these a try, or I'll mess with it a bit more and see what I can figure out.

Glad it's working for you!

PornulusRift

  • VR Porn Fiend
  • ***
  • Posts: 91
    • PornulusRift
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #7 on: December 01, 2014, 05:05:12 AM »
I got it so that the model is always facing the CenterEyeAnchor.  With this, the model's face is always facing the players eyes.  I think with a bit of modification we could probably repurpose the headlookcontroller to be used on the eye bones, so that also the eyes could look into the players eyes.

Code: [Select]
// Desired look direction in world space
//Vector3 lookDirWorld = (target - segment.lastTransform.position).normalized;
Vector3 lookDirWorld = (targetObject.transform.Find("OVRCameraRig/CenterEyeAnchor").position - segment.lastTransform.position).normalized;

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #8 on: December 01, 2014, 09:08:38 AM »
Wow - nicely done! The effect is subtle but really engaging. I think you're onto something - could have her pick an eye randomly to look into, and switch on a random period. Might be interesting to see what happens if we use the lookAt algorithm for the eye bones for that, so we get some natural life in the eyes.

(Open-sourced VR hentai software development - I love it! ;) )

PornulusRift

  • VR Porn Fiend
  • ***
  • Posts: 91
    • PornulusRift
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #9 on: December 01, 2014, 09:32:58 AM »
With the change I mentioned above for the center eye anchor, here are some example parameters I'm using for eye, head, and neck tracking:


And here's a demo using them:
http://www.mediafire.com/download/hy0zhf6sp3rby5g/head_track_test_v2.rar

You'll notice I'm using Eye->EyeTip and not Head->Eye.  When using Head->Eye the tracking seemed wrong.  I set the response time for the eyes up to 100 since people tend to move their eyes instantly when they look at something.  Also, I lowered the max bend angle for the eyes to 20, so they don't roll behind her head lol.
« Last Edit: December 01, 2014, 10:10:21 AM by fireflame »

PornulusRift

  • VR Porn Fiend
  • ***
  • Posts: 91
    • PornulusRift
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #10 on: December 01, 2014, 10:24:13 AM »
I think the settings still need tweaked in some way, but I'm not sure how.  The eyes seems to look too far to the side if you are facing her then move about 1-2 feet right or left.

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #11 on: December 01, 2014, 12:49:38 PM »
I love it! Moving the eyes definitely makes a difference! I wonder if randomly switching the player eye she looks into could give you the 'flicking' motion that real people do when they look into your eyes.

Love where this is going!

Syncret

  • VR Porn Fiend
  • ***
  • Posts: 54
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #12 on: December 01, 2014, 04:43:49 PM »
Thanks so much for sharing your settings! They work out well.

Did a quick scene trying them out:

Download:
https://www.mediafire.com/?7zzgub0yigd77rt

buckjohnston

  • Guest
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #13 on: December 03, 2014, 12:13:58 PM »
This is good, but she needs to look away with her head and eyes every once in a while. Kind of like this demo does: http://tore-knabe.com/virtual-reality#CoffeeWithoutWords or something like this:

The miku in your demo kind of looks like a man also. Maybe Try one of these high quality TDA one's listed http://kinoshitakitsune.deviantart.com/journal/MMD-Download-TDA-Append-Models-410835442  (the first one is listed there is used in the video I linked to.)

Here is what I am working on utilizing first model. The immersion factor for VR in the small details that nobody cares about on a monitor. Let's give these Miku's some life! :)

PornulusRift

  • VR Porn Fiend
  • ***
  • Posts: 91
    • PornulusRift
Re: Tutorial - Dynamic Head Tracking in Unity3D
« Reply #14 on: December 04, 2014, 06:16:17 PM »
This is good, but she needs to look away with her head and eyes every once in a while. Kind of like this demo does: http://tore-knabe.com/virtual-reality#CoffeeWithoutWords or something like this:

The miku in your demo kind of looks like a man also. Maybe Try one of these high quality TDA one's listed http://kinoshitakitsune.deviantart.com/journal/MMD-Download-TDA-Append-Models-410835442  (the first one is listed there is used in the video I linked to.)

Here is what I am working on utilizing first model. The immersion factor for VR in the small details that nobody cares about on a monitor. Let's give these Miku's some life! :)

Great, cant wait to see it!  Are you making your own animations?

 

* Download VRtitties

* VRtitties Affiliate Links

* Forum Staff

Will admin Will
Administrator