Jump to content
abrakadobr

How to get player head orientation on server side?

Recommended Posts

Hi all!

I'm trying to get players body and head orientation on server side (when player hold Alt key and rotate head independently of body) - any clue how can I get it?

`player.GetDirection()` and `player.m_CharactersHead.GetDirection()` same as bones head and neck `GetBoneRotationWS` are always same whatever direction head is looking 😞  but for sure there is somewhere this information on server side

Share this post


Link to post
Share on other sites

I spent lot of time searching it my side but never found.
If at some point you find it it, pls share

Share this post


Link to post
Share on other sites

I took a quick look at the source code of the mod SchanaModCompass where the compass updates no matter if you turn your entire body or just your head. I found this method which returns the angel the camera is looking at. Not sure if that's what you are looking for but here it is anyways.

    float SchanaGetAngle () {
        vector direction = GetGame ().GetCurrentCameraDirection ();
        float angle = direction.VectorToAngles () [0];
        return angle;
    }

 

Edited by NoBeansForMe

Share this post


Link to post
Share on other sites

 

On 7/5/2022 at 10:18 PM, NoBeansForMe said:

I took a quick look at the source code of the mod SchanaModCompass where the compass updates no matter if you turn your entire body or just your head. I found this method which returns the angel the camera is looking at. Not sure if that's what you are looking for but here it is anyways.


    float SchanaGetAngle () {
        vector direction = GetGame ().GetCurrentCameraDirection ();
        float angle = direction.VectorToAngles () [0];
        return angle;
    }

 

Thank you for trying to help but this peace of code only provide the angle of the camera, not the angle of the head.
In my case it makes a big difference.

Share this post


Link to post
Share on other sites
On 7/1/2022 at 12:04 PM, abrakadobr said:

Hi all!

I'm trying to get players body and head orientation on server side (when player hold Alt key and rotate head independently of body) - any clue how can I get it?

`player.GetDirection()` and `player.m_CharactersHead.GetDirection()` same as bones head and neck `GetBoneRotationWS` are always same whatever direction head is looking 😞  but for sure there is somewhere this information on server side

Mate you shall know about PBO MAnagers. So most of answers you may find at: %DayZGameFolder\dta\scripts.pbo.

Now some answers on your question:
1. %DayZGameFolder\dta\scripts\4_World\Entities\ManBase\PlayerBase.c
(you may request that info from severs side with GetGame.GetPlayers()) like:
array<Man> players = new array<Man>; //Prepare store l;ist.
GetGame().GetPlayers( players );            // Get players list

for (int i =  0; i < players .Count(); i++)
{
            PlayerBase player_unit = PlayerBase.Cast(players.Get(i)); // Get player
            // Do what ever you want
}

Now (PlayerBase.c line 2575):
// freelook camera memory for weapon raycast; m_DirectionToCursor is vector type.
        if (hic.CameraIsFreeLook() && m_DirectionToCursor == vector.Zero)
        {
            m_DirectionToCursor = GetGame().GetCurrentCameraDirection();
        }
        else if (!hic.CameraIsFreeLook() && m_DirectionToCursor != vector.Zero)
        {
            m_DirectionToCursor = vector.Zero;
        }

Else (PlayerBase.c line 7227):
//Get aim (player crosshair) position
    vector GetAimPosition()
    {
        float min_distance = 0.5;        //min distance, default = 5m
        
        vector from = GetGame().GetCurrentCameraPosition();
        vector to = from + (GetGame().GetCurrentCameraDirection() * min_distance);
        vector contactPos;
        vector contactDir;
        int contactComponent;
        
        DayZPhysics.RaycastRV( from, to, contactPos, contactDir, contactComponent, NULL, NULL, NULL, false, true );
        
        return contactPos;
    }

Checkout the function GetAimPosition() those variables may give you what you need to find.

Edited by Sid Debian

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×