Camera to Z-player position

0xNull

Member
Joined
Jul 14, 2018
Messages
24
Reaction score
0
Hello everybody. I continue to do Aim for GTA sa. Faced such a problem:

I found the coordinates X and Y, which need to be guided. But how to point the camera at the Z coordinate of another character?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Hello, I think that's what you're looking for:
https://www.e-education.psu.edu/natureofgeoinfo/book/export/html/1837

Here's a python code that calculates the slope degree (that 'vertical angle' so you know how far 'vertically rotate' the camera):
PHP:
from math import sqrt , atan, pi

pos = dict(
   x=0,
   y=0,
   z=0
   )

his_pos = dict(
   x=6,
   y=8,
   z=10
   )

def get_2d_distance(x,y, x2, y2):
   '''Pythagorean theorem'''
   return sqrt((x - x2) ** 2 +  (y - y2) ** 2)

run = get_2d_distance(
   pos['x'], pos['y'],
   his_pos['x'], his_pos['y']
   )

rise = his_pos['z'] - (pos['z'] + 0.6) # vertical difference between camera attachment and him (between camera attachment Z position and his Z-position)

slope_degree = atan(rise/run) * 180 / pi

print "run={0} - it's like 2D distance".format(run)
print "rise={0} - difference between your z-position and his z-position".format(rise)
print "slope_angle={0} - that's what you looking for I guess".format(slope_degree)

Edit: quick formula would be:
slope_degree = atan((z - (z2 + 0.6)) / sqrt((x - x2) ** 2 + (y - y2) ** 2)) * 180 / pi

where "** 2" stands for the power of 2,
and "* 180 / pi" is just for conversion of radians to degrees
and where z2 is the "z" position of local player

Edit2:
so the output of the program is:
run=10.0 - it's like 2D distance
rise=10 - difference between your z-position and his z-position
slope_angle=45.0 - that's what you looking for I guess

Edit3:
The Z coordinate of your own player has to be increased by 0.6 for accurate calculation (at least when you're on foot), that is because the camera rotates around that exact spot. So I edited the code and formula above
 
Last edited:

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
0A8C: write_memory 0xB6F258 size 4 value 4@ virtual_protect 0 // CameraXAngle: 0xB6F258 size 4(float) :: CameraYAngle add 0x4 to 0xB6F258
 

0xNull

Member
Joined
Jul 14, 2018
Messages
24
Reaction score
0
monday said:
Hello, I think that's what you're looking for:
https://www.e-education.psu.edu/natureofgeoinfo/book/export/html/1837

Here's a python code that calculates the slope degree (that 'vertical angle' so you know how far 'vertically rotate' the camera):
PHP:
from math import sqrt , atan, pi

pos = dict(
   x=0,
   y=0,
   z=0
   )

his_pos = dict(
   x=6,
   y=8,
   z=10
   )

def get_2d_distance(x,y, x2, y2):
   '''Pythagorean theorem'''
   return sqrt((x - x2) ** 2 +  (y - y2) ** 2)

run = get_2d_distance(
   pos['x'], pos['y'], 
   his_pos['x'], his_pos['y']
   )

rise = his_pos['z'] - pos['z'] # vertical difference between you and him (between your Z-position and his Z-position)

slope_degree = atan(rise/run) * 180 / pi

print "run={0} - it's like 2D distance".format(run)
print "rise={0} - difference between your z-position and his z-position".format(rise)
print "slope_angle={0} - that's what you looking for I guess".format(slope_degree)

Edit: quick formula would be:
slope_degree = atan((z - z2) / sqrt((x - x2) ** 2 +  (y - y2) ** 2)) * 180 / pi

where "** 2" stands for the power of 2,
and "* 180 / pi" is just for conversion of radians to degrees

Edit2:
so the output of the program is:
run=10.0 - it's like 2D distance
rise=10 - difference between your z-position and his z-position
slope_angle=45.0 - that's what you looking for I guess
Thanks for your wonderful formula, I think it will be useful somewhere else. But I wanted to find the OFFSET Z-camera position :D Ie where the player's camera is looking
 
Top