AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Coordinates of the player's camera first person view (https://forums.alliedmods.net/showthread.php?t=322396)

tonline_kms65 03-26-2020 04:17

Coordinates of the player's camera first person view
 
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);

Bacardi 03-26-2020 12:51

Re: Coordinates of the player's camera first person view
 
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)

tonline_kms65 03-26-2020 16:58

Re: Coordinates of the player's camera first person view
 
1 Attachment(s)
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?

Bacardi 03-26-2020 17:21

Re: Coordinates of the player's camera first person view
 
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 ?

tonline_kms65 03-26-2020 17:26

Re: Coordinates of the player's camera first person view
 
If you tie a player's skeleton to the bones - this is not good, the bones move - the camera also moves.

tonline_kms65 03-26-2020 17:28

Re: Coordinates of the player's camera first person view
 
Quote:

Originally Posted by Bacardi (Post 2688707)
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 03-26-2020 17:31

Re: Coordinates of the player's camera first person view
 
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)

Bacardi 03-26-2020 17:31

Re: Coordinates of the player's camera first person view
 
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 ?

tonline_kms65 03-26-2020 17:43

Re: Coordinates of the player's camera first person view
 
I'm on my way to work now. I'll come home from work, check it out, and let you know.

Balimbanana 03-26-2020 19:34

Re: Coordinates of the player's camera first person view
 
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.


All times are GMT -4. The time now is 04:01.

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