Head tracking for player character

Post » Sun Jun 24, 2012 3:25 pm

Hi there,

I'm currently trying to create a mod to make the player character use the same head tracking functionality NPCs use when they're talking to you. Currently the player character just stares straight ahead, ignoring NPCs who are speaking to him and it kinda ruins the immersion if you enjoy playing in third person.

I've never modded Skyrim or a Bethesda game before but I do write mobile phone apps for a living so it wasn't too difficult to get the gist of things. Digging through the API reference I see several methods that look relevant: Actor.SetHeadTracking, Actor.SetLookAt, Actor.ClearLookAt

Unfortunately I couldn't get these to do what I wanted. Now, I know how to program, but I don't know much about the CK itself, so I'm not sure if I'm just doing something wrong in the editor or just not understanding some elements of Papyrus, or if the issue is something else, but any assistance would be appreciated.

I started off by adding a new script to the Player actor in the CK, and writing the following code:

Scriptname PlayerHeadTracking extends ObjectReferenceActor Property lydiaRef AutoActor Property pcRef Autobool isEnabledEvent OnInit()Debug.Notification("Loaded plugin.")RegisterForSingleUpdate(5)EndEventEvent OnUpdate()if isEnabled == true  Debug.Notification("Clearing look target.")  pcRef.ClearLookAt()Else  Debug.Notification("Looking at target.")  pcRef.SetHeadTracking(true)  pcRef.SetLookAt(lydiaRef)EndIfisEnabled = !isEnabledRegisterForSingleUpdate(5)EndEvent

I basically wanted to try getting the head tracking part down before worrying about the other bits (where to attach the script, who to look at, etc.) so I made this simple script that simply alternates between looking at Lydia and clearing the target every 5 seconds. Unfortunately, it doesn't work. I get all of the relevant notification messages so the script is running, but the SetLookAt function doesn't appear to do anything.

I have swapped the references (making Lydia look at the player) and it works fine, so I don't think I'm making any issues with the editor, but I'm not certain. Perhaps I have to do something special with the player actor to be able to "modify" him? I'm not sure.

I suspect it might actually have something to do with the idle animation... the default idle animation for the player has them glance around at nothing in particular, not using head tracking, just as part of the general idle animation. NPCs don't seem to do this... they're always moving their head to look at another actor or object it seems. I wonder if the player character has a different idle animation that overrides any head movement I might set, and if so, would there be a way to remove such an animation?

Any ideas?
User avatar
x_JeNnY_x
 
Posts: 3493
Joined: Wed Jul 05, 2006 3:52 pm

Post » Sun Jun 24, 2012 4:38 pm

I am writing this from a mobile device with zero current access to the CK or the game but I am almost positive that the player does not have any HeadIK thus those functions would never work unless you correct that first.
User avatar
Chris Duncan
 
Posts: 3471
Joined: Sun Jun 24, 2007 2:31 am

Post » Sun Jun 24, 2012 3:38 am

I am writing this from a mobile device with zero current access to the CK or the game but I am almost positive that the player does not have any HeadIK thus those functions would never work unless you correct that first.

Thanks for the heads up. At least now I can stop messing around with idle animations and console commands (I was able to get the player to rotate towards the look target, but only if I used TC to make them AI driven. Still no head movement).

Could you elaborate on what HeadIK is? Is it a part of the skeleton/animation rig or is it something else? I had figured that for all intents and purposes the player was just treated as another actor by the game (using the same meshes/textures/animations/etc. as NPCs, just with player controls) but clearly this isn't entirely true. How would I go about adding whatever HeadIK is to the PC? And would it be inordinately difficult to do so? Like I said in my main post, I'm a programmer so if it's just a matter of messing around with scripts or various CK resources I can handle that. But if it has something to do with the 3D model or skeleton I'm probably screwed. Or at least, I'll have to download Blender and spend some time working with a bunch of tutorials first.

Either way, I really appreciate the information. I was getting frustrated with trying to get it to work, not sure if it could be solved by tweaking animations or code or if it was just not possible the way I was approaching it. :S Thanks.
User avatar
Danii Brown
 
Posts: 3337
Joined: Tue Aug 22, 2006 7:13 am


Return to V - Skyrim