Skyrim
0 of 0

File information

Last updated

Original upload

Created by

hiryuu19

Uploaded by

hiryuu19

Virus scan

Safe to use

Tags for this mod

116 comments

  1. hiryuu19
    hiryuu19
    • member
    • 13 kudos
    Locked
    Sticky
    I just got a notification from the new premium rewards feature and realized that this mod has over 10,000 unique downloads. I know it's not perfect, but I still want to thank everyone for their interest.

    I have also received a few requests for information regarding the mod and.  As something I had been wanting to do for some time, I am posting my source code here. I thought it had been lost in a move to a new computer (forgot to transfer/backup), but I found a copy in an old DM to a previous requester. Even though I will not be spending the time to debug this mod further or implement other mods in the near future on this site, hopefully someone will be able to make use of this logic to make something interesting.

    I give full permission to use this code without restriction and bear no responsibility for its use by another developer. If you are feeling charitable, credit me in comments and/or on your mod.

    HeadTracker.psc
    ---
    Scriptname HeadTracker extends Quest

    Actor PlayerRef
    ObjectReference Target

    int function track(Actor PlayerRefIn, ObjectReference TargetIn)
    PlayerRef = PlayerRefIn
    Target = TargetIn
    ;Debug.Notification("Starting track for player and target " + Target.getFormId())
    RegisterForSingleUpdate(0)
    return 12345
    endfunction

    Event OnInit()
    ;Debug.Notification("HeadTracker init() no-op")
    ; no-op
    EndEvent

    Event OnUpdate()
    PlayerRef.SetAnimationVariableInt("IsNPC", 1)
    PlayerRef.SetHeadTracking(true)
    PlayerRef.SetLookAt(Target)
    RegisterForSingleUpdate(0)
    EndEvent
    ...
     
    And the core function from my main.cpp (ignoring SKSE registering functions and all that):
    ---
    #include "skse/PluginAPI.h" // super
    #include "skse/skse_version.h" // What version of SKSE is running?
    #include "skse/GameReferences.h"
    #include "skse/GameCamera.h"
    #include "skse/NiNodes.h"
    #include "skse/PapyrusNativeFunctions.h"
    #include <cmath>
    #include <shlobj.h>

    #define PI 3.1415926
     
    [skse stuff]
     
    extern "C" {
     
    [skse stuff]
     
    namespace HeadTrack {

    float halfpi = PI / 2;
    float PI3 = PI * 3;
    float dist = 12000.0;
    NiPoint3 dummy;

    void MoveObject(StaticFunctionTag *base, TESObjectREFR * obj) {
    PlayerCamera * pcam = PlayerCamera::GetSingleton();
    float(*data)[3] = PlayerCamera::GetSingleton()->cameraNode->m_worldTransform.rot.data;

    float trigZ;
    float aZ = atan2(data[0][0], data[1][0]);
    if (aZ < halfpi){
    trigZ = PI - aZ;
    } else {
    trigZ = PI3 - aZ;
    }

    float trigX = atan2(data[2][1], data[2][2]);

    obj->pos.y = (*g_thePlayer)->pos.y + (dist * sin(trigZ));
    obj->pos.x = (*g_thePlayer)->pos.x + (dist * cos(trigZ));
    obj->pos.z = (*g_thePlayer)->pos.z + 130 + (dist * sin(trigX));
    }

    void RotateHead(StaticFunctionTag *base){
    // This is wrong- the rotation matrix from cam is world aligned, player transform relative to facing.
    // additionally, this only rotates the head without any modification to the body- without bounds!
    // Added note 2024: this was an attempt to rotate the head without using the SetLookAt function in scripting. The result was much faster, reduced scripting overhead, and did turn the head- but detached the head mesh at the neck. I didn't have the knowledge to make the rotation with mesh deformations as desired and had to give up on this approach.
    (*g_thePlayer)->GetFaceGenNiNode()->ApplyTransform(&PlayerCamera::GetSingleton()->cameraNode->m_worldTransform.rot,
    &dummy, true);
    }

    bool RegisterFuncs(VMClassRegistry* registry) {
    registry->RegisterFunction(
    new NativeFunction1 <StaticFunctionTag, void,
    TESObjectREFR *>("MoveObject", "HeadTrack", HeadTrack::MoveObject,
    registry));
    registry->RegisterFunction(
    new NativeFunction0 <StaticFunctionTag, void>("RotateHead",
    "HeadTrack", HeadTrack::RotateHead, registry));
    return true;
    }
    }
     
    [skse stuff]
     
    }
  2. hiryuu19
    hiryuu19
    • member
    • 13 kudos
    Sticky
    I have uploaded a new version with MCM configuration for keys, script delay, and first person disable. The disable is tested with vanilla and seems to work well to fix the bugs there. The script delay was added to allow greater delay in attempt to reduce script load on slower systems. I am not sure how useful the feature will actually be, but it is available. The toggle key is now configurable along with the pose key, which will stop the object movement while continuing headtracking. Toggling the mod off and on will reset the pose state. If you change the toggle key while the mod is disabled, the script does not update the key until it is toggled back on. You must press the old key to reenable the mod or, preferably, change the toggle key while the mod is active.
    1. SZ818
      SZ818
      • member
      • 7 kudos
      pretty good mod, but yeah perhaps is not that my system can't handle recursive scripts but that i already have many of them, if there were a chance to make the head tracking snap at objects or people near or under the cursor it would be better, there is the other head tracking mod that almost do this except it does automatically and not under the cursor and the character looks kind of retarded looking at everything everywhere and trying to focus always on companions and followers behind him or her
  3. oblivionluvr17
    oblivionluvr17
    • supporter
    • 0 kudos
    At first this worked wonderfully.

    Now in first person the cursor appears on forearm or fist when aiming up:

    https://imgur.com/a/AayKbHp

    Just a heads up in case others are seeing this same error and not realizing what may be the cause. I disabled over 200 mods and tested enabling three at a time to determine the cause. Had I realized this was the issue I could have saved a ton of time.

    Anyhow in hindsight I now know what the 'toggle' feature is for. It disables head tracking in moments you don't want this mod affecting your use--like when aiming in first-person. (I feel so silly for not realizing that).

    Oh. Yes, am running the updated mod version.

    This is an excellent mod other than that odd situation. Thx
  4. cronodoug
    cronodoug
    • member
    • 11 kudos
    Simple and efficient!
  5. JIYONTEKUZA
    JIYONTEKUZA
    • supporter
    • 0 kudos
    In the video I noticed I could see the Player Character's shadow in 1st person as he headed down the stairs. In my game, my Player Character's shadow disappears when in first person. Is this an ENB or am I doing something wrong?
    1. Rostorman
      Rostorman
      • member
      • 2 kudos
      У меня тень от 1 лица
      https://b.radikal.ru/b41/2104/4a/9a9a94e35d7b.png
  6. Rostorman
    Rostorman
    • member
    • 2 kudos
    A chic mod for sharing with First Person v,1,9 No Projecting
  7. Deadspace1
    Deadspace1
    • member
    • 1 kudos
    could you make a fallout 4 port of this?
  8. JadeMythriil
    JadeMythriil
    • member
    • 1 kudos
    THere is a problem when using the bow. When I try aiming with a bow, since the body twists where I aim, when the game tries head tracking where I'm aiming, the model starts twisting very oddly(head starts to twist between the legs when I look down and doing a full back stretch when I look up almost like their back is double jointed.)
  9. deleted45137327
    deleted45137327
    • account closed
    • 0 kudos
    I'm having a bit of a problem... again. The mod was working fine until I joined Volkihar Clan (Dawnguard DLC) after my character got the power of Lord Vampire, I realized that the mod stopped working, I thought I had disabled it by using the default key "V" , but no, it just does not work, sometimes it works and it's like the character tries to locate the crosshair, but it gets bugged and he just stares at the floor or at his back. It's weird, I tried reinstalling, completely deleting the mod and reinstalling it, loading old save games (In previous games to the DLC the mod is working fine), it seems the mod does not work with the bestial form of the vampires, or something caused it to behave like this. Any solution?

    Before becoming a vampire:

    https://i.imgur.com/BehMbKu.jpg (As you can see, my character follows the crosshair correctly)
    https://i.imgur.com/hhuVGy6.jpg

    After becoming a vampire:

    https://i.imgur.com/icqhTA5.jpg (As you can see, he's not even staring at the crosshair anymore, he's just focusing on something else, but not the camera)
    https://i.imgur.com/wvBsnVb.jpg
    https://i.imgur.com/yMsYOGe.jpg (Yes, I also thought it was a problem with the "pose key" because this key does something similar when you activate it, but no, the mod is simply broken and I do not know how to fix it)

    I use the Steam Version of the game, If somebody can help me, I'll appreciate it so much. (Sorry if I have some grammar mistakes, English is not my first language)
  10. Tissendel
    Tissendel
    • supporter
    • 89 kudos
    Super mod, great job, loving it ^^

    Will there be a SE port ? If not, can we have SKSE ddl source ?
  11. Ihn
    Ihn
    • premium
    • 0 kudos
    Very good 10/10 mod, 100% essential and one of my favorites.

    I got SE, I started to modify and I try to find it among the innumerable modifications for SE, a pity that I have not found it.

    Will there be availability in Skyrim SE?
  12. deleted45137327
    deleted45137327
    • account closed
    • 0 kudos
    I am having a bit of an annoying bug, sometimes when my character is standing and watching something for some time, there will be a "reset", like a "shake" in his head, and after that "shake", his head will be again watching the camera crosshair. It's weird, any fix?
    1. TheXa0sfact0r
      TheXa0sfact0r
      • supporter
      • 0 kudos
      Are you using version 1.2? Or are you using version 1.0, the files on this page seem to be in the wrong order, but the bug you're reporting seems exactly like one I was experiencing before upgrading to the newest version.