View Single Post
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 06-09-2009 , 13:48   Re: Place model\image\sprite in constant position on screen
Reply With Quote #4

Both me and stupok, tried to put sprites as if they were in the hud but with no success, when the user moves. The sprite position is always delayed. I even tried to added the vector velocity but it just make it worst. Maybe it can be achieved but I doubt it.

This is the code I was using:

PHP Code:
ent create_entity("env_sprite")
entity_set_model(ent,spriteModel)
set_pev(ent,pev_scale,0.02)
DispatchSpawn(ent); 
PHP Code:
static Float:start[3], Float:view_ofs[3], Float:origin[3]

pev(id,pev_origin,origin);

new 
Float:angles[3]
pev(id,pev_v_angle,angles)

new 
Float:path[3]

angle_vector(angles,ANGLEVECTOR_FORWARD,path)
xs_vec_normalize(path,path)
xs_vec_mul_scalar(path,4.0,path);
xs_vec_add(path,origin,origin)

angle_vector(angles,ANGLEVECTOR_RIGHT,path)
xs_vec_normalize(path,path)
xs_vec_mul_scalar(path,-2.5,path);
xs_vec_add(path,origin,origin)

angle_vector(angles,ANGLEVECTOR_UP,path)
xs_vec_normalize(path,path)
xs_vec_mul_scalar(path,-2.0,path);
xs_vec_add(path,origin,origin)

new 
Float:vofs[3]
pev(id,pev_view_ofs,vofs)
xs_vec_add(origin,vofs,origin)

entity_set_origin(ent,origin);
set_pev(ent,pev_angles,angles
About this code, you shall create the entity anywhere and then use a forward, i tried with PlayerPreThink, to do the calculations.
__________________

Last edited by joaquimandrade; 06-09-2009 at 13:53.
joaquimandrade is offline