Jump to content

Home

View Angle


Blinkity

Recommended Posts

Hello. I'm wondering, to all the experienced coders out there, if you know of any way to access the direction that a client's view is pointing in. I'm looking for a vector that contains the relative amounts on the x, y, and z axis that a straight line would bring you. This would be so that I can easily change the client's velocity to accelerate them in the direction they are pointing, including vertically. If anybody knows if there is a vector containing this information at any given time, it would be much appreciated.

 

Thanks,

Blinkity

Link to comment
Share on other sites

i myself used a trace

dont know about viewangles, but the trace worked:

vec3_t a;
vec3_t tfrom, tto, fwd;
vec3_t		center, forward, right, fwdangles = {0};
trace_t tr;

int			radius = 1024;


VectorCopy( ent->client->ps.viewangles, fwdangles );
AngleVectors( fwdangles, forward, right, NULL );
VectorCopy( ent->client->ps.origin, center );




VectorCopy(ent->client->ps.origin, tfrom);
tfrom[2] += ent->client->ps.viewheight;
AngleVectors(ent->client->ps.viewangles, fwd, NULL, NULL);
tto[0] = tfrom[0] + fwd[0]*radius/2;
tto[1] = tfrom[1] + fwd[1]*radius/2;
tto[2] = tfrom[2] + fwd[2]*radius/2;

trap_Trace(&tr, tfrom, NULL, NULL, tto, ent->s.number, MASK_PLAYERSOLID);

 

This raises the trace origin to eyes height and traces in a small radius in the forward direction

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...