Raised This Month: $32 Target: $400
 8% 

Solved Coordinates of the player's camera first person view


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 03-26-2020 , 04:17   Coordinates of the player's camera first person view
Reply With Quote #1

Hello everyone.
Tell me the position where the player's camera is located, first-person view.
How to get the coordinates of the player's camera, first-person view.

The player's eye position is the player's camera position?
GetClientEyePosition(client, pos);

Last edited by tonline_kms65; 03-28-2020 at 00:40.
tonline_kms65 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-26-2020 , 12:51   Re: Coordinates of the player's camera first person view
Reply With Quote #2

Yes. Usually locate just behind head of player model (depends player model).
GetClientEyePosition
https://sm.alliedmods.net/new-api/sd...entEyePosition

You get common problem when use SDKTools TraceRay function, you will hit player model and you need filter that out.


GetClientAbsOrigin
https://sm.alliedmods.net/new-api/cl...lientAbsOrigin
Origin under feet (depends how player model has created)
__________________
Do not Private Message @me
Bacardi is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 03-26-2020 , 16:58   Re: Coordinates of the player's camera first person view
Reply With Quote #3

Ok. Thanks.

I create an ENT camera on the coordinates of the player's eye:
Code:
int ent_camera = CreateEntityByName("prop_physics_override");
        SetEntityModel(ent_camera, ENT_CAMERA); // 3D model of my camera 
        DispatchSpawn(ent_camera);
        DispatchKeyValue(ent_camera,"classname", "class_vmodel_camera");
        DispatchKeyValue(ent_camera, "solid", "0");
        TeleportEntity(ent_camera, pos, ange, NULL_VECTOR); // position and direction of the player's gaze
Then the problems begin:
I'm trying to get my 3D camera model to follow the player always at the position of their eyes.
Code:
Format(ParentCamera, sizeof(ParentCamera), "%i", client);
        DispatchKeyValue(client, "targetname", ParentCamera);
        SetVariantString(ParentCamera);
        AcceptEntityInput(ent_camera, "SetParent");
But the center of my ENT camera always turns out to be under the player's feet(the camera position is correct, but its center is not where I need it).
[url]https://forums.alliedmods.net/attachment.php?
Attached Images
File Type: jpg pos01.jpg (40.4 KB, 122 views)

Last edited by tonline_kms65; 03-26-2020 at 17:21.
tonline_kms65 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-26-2020 , 17:21   Re: Coordinates of the player's camera first person view
Reply With Quote #4

Does it change if you set higher ?
pos[2] += 64.0;

Could parenting do something weird... maybe player model parent attachment is another option.

*edit
Or did csgo players have own view entity ?
__________________
Do not Private Message @me

Last edited by Bacardi; 03-26-2020 at 17:22.
Bacardi is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 03-26-2020 , 17:26   Re: Coordinates of the player's camera first person view
Reply With Quote #5

If you tie a player's skeleton to the bones - this is not good, the bones move - the camera also moves.
tonline_kms65 is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 03-26-2020 , 17:28   Re: Coordinates of the player's camera first person view
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
Does it change if you set higher ?
pos[2] += 64.0;

Could parenting do something weird... maybe player model parent attachment is another option.

*edit
Or did csgo players have own view entity ?
Yes, it is changing. But I need to shift the center to properly snap the camera.
tonline_kms65 is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 03-26-2020 , 17:31   Re: Coordinates of the player's camera first person view
Reply With Quote #7

There may be an error in the binding code:
PHP Code:
Format(ParentCamerasizeof(ParentCamera), "%i"client);
        
DispatchKeyValue(client"targetname"ParentCamera);
        
SetVariantString(ParentCamera);
        
AcceptEntityInput(ent_camera"SetParent"); 
There may be other methods (other than binding to certain bones and attachments)

Last edited by tonline_kms65; 03-26-2020 at 17:32.
tonline_kms65 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-26-2020 , 17:31   Re: Coordinates of the player's camera first person view
Reply With Quote #8

I tested between eyes and abs, I got these Z values
Code:
32.310600
96.310600
So difference is 64.

If you are teleporting too soon on player while he spawn for example ?
__________________
Do not Private Message @me
Bacardi is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 03-26-2020 , 17:43   Re: Coordinates of the player's camera first person view
Reply With Quote #9

I'm on my way to work now. I'll come home from work, check it out, and let you know.
tonline_kms65 is offline
Balimbanana
Member
Join Date: Jan 2017
Old 03-26-2020 , 19:34   Re: Coordinates of the player's camera first person view
Reply With Quote #10

Try this:
Code:
SetVariantString("!activator");
AcceptEntityInput(ent_camera,"SetParent",client);
SetVariantString("eyes");
AcceptEntityInput(ent_camera,"SetParentAttachment");
The action of SetParentAttachment will also set the origin, so no need for the teleport either. It is also safe to use ActivateEntity(ent_camera); after DispatchSpawn just in case.

Then, if the offset needs to be modified, you could use the "m_vecOrigin" vector property to set the attachment offset. By default after using SetParentAttachment is 0 0 0. This is not the same as "m_vecAbsOrigin" and it is also different from TeleportEntity.

Last edited by Balimbanana; 03-26-2020 at 19:36.
Balimbanana is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode