Page 1 of 1

Getting Eye Angle of player

Posted: Sat May 10, 2014 8:44 pm
by arawra
What I would like to do is compare the eye angle of two players to determine if a player is behind another. I'm not seeing any properties in PlayerEntity for this, and was wondering if the functionality exists.

Posted: Sat May 10, 2014 8:57 pm
by satoon101
You can use the links in this thread to see the "sp dump server_classes" output for the given games (though some might need updating). Just because we don't have the send property assigned to PlayerEntity doesn't mean it doesn't exist. That just means we haven't added support for in the BaseEntity structure.

Posted: Fri May 16, 2014 11:44 am
by arawra
Would I have to scan the signature for "float m_angEyeAngles[0] (offset 8404)" in CCSPlayer, or is there a way to interact directly with CCSPlayer in Python?

Tried using:

Syntax: Select all

PlayerEntity(player)._get_property('m_angEyeAngles[0]')
PlayerEntity(player)._get_property('m_angEyeAngles')[0]

Posted: Fri May 16, 2014 12:27 pm
by arawra
Got it.

PlayerEntity(player).eye_angle_x
PlayerEntity(player).eye_angle_y

Posted: Fri May 16, 2014 12:34 pm
by Ayuto
You could either access the eye angle by using (<edict>.get_prop_float('m_angEyeAngles[0]'), <edict>.get_prop_float('m_angEyeAngles[1]'), <edict>.get_prop_float('m_angEyeAngles[2]')) or by using PlayerEntity.

Syntax: Select all

from players.entity import PlayerEntity

player = PlayerEntity(<index>)
print((player.eye_angle_x, player.eye_angle_y))
We have not added eye_angle_z, because it's always 0 (I think).