PDA

View Full Version : Camera origin



randall
17th June 2013, 12:53
Hi,

is it any method to get the origin of the camera view? I know the "tag_eye", but it works aright only in first person, but I use thirdperson in my mod. So can I solve somehow that the players shoot the center of the view?

kung foo man
17th June 2013, 15:48
Hey, i've a good function for that, but the problem is, that it needs getStance(), which is no default function (you need to find it somewhere or maybe somebody will post here some hints).



getRealEye()
{
player = self;

stance = player std\player::getStance();

offset = 0;
switch (stance)
{
case "stand": offset = 20; break;
case "duck": offset = 0; break;
case "lie": offset = -30; break;
//default: offset = getcvarint("offset");
}

realEye = player getEye() + (0,0,offset);
return realEye;
}


Maybe player getEye() is also already good enough?

randall
17th June 2013, 17:36
I thought for this:
314

In 3rd person if I'm looking up/down or leaning, the player don't shoot at the center of the view camera.

IzNoGoD
17th June 2013, 17:59
If i remember correctly, the 3rd person used a few client-cvars to determine camera offsets. Maybe those will provide you with the insight you need?
They should all start with cg_thirdperson.

randall
17th June 2013, 18:45
I'd like to make only a 3rd person mod but i don't know how to solve the exact shooting.

kung foo man
18th June 2013, 17:36
Thought some time over it, but the only solution seems to be engine hacking.



onShoot {
manipulate bullet origin for left/right leaning
}

randall
18th June 2013, 18:11
I thought I cannot solve this :(

megazor
6th July 2013, 05:24
The camera position in thirdperson is defined by a vector from the player's head, which length is the client cvar cg_thirdPersonRange, and direction can be counted by the player's up angle of view - the stock function getPlayerAngles()[0]. So,

1) get the eye position;
2) knowing that cg_thirdpersonrange is cheat-protected and thus can't be changed by client unless hacked/devmap, you will want to use its default value, 120;
3) convert player angles to vector;
4) multiply 2) by 3) and you have it.

The only problem here is, there is NO CLIPPING! The camera position calculated by this algorithm may get into solid objects, whereas actual camera has collision check. Well, you can simply BulletTrace() it then.

kung foo man
6th July 2013, 10:35
Yea, that camera-position could be calculated, but he needs to modificate the origin of thirdperson-bullets

IzNoGoD
6th July 2013, 20:13
Take a look at the cod4mod firing through walls code for ideas on that :)

randall
7th July 2013, 13:09
Im interesting for the 3rd person camera origin, not for the tag_eye's origin..