vec_for_ent (VECTOR*, ENTITY*)

vec_to_ent (VECTOR*, ENTITY*)

Converts the given position vector from the entity coordinate system to a world position (vec_for_ent), resp. from a world position to the entity coordinate system (vec_to_ent). World coordinates are calculated from entity coordinates through rotating, scaling, and translating the vector by the entities' angle, scale, and position.  A7.08 

Parameters:

VECTOR* Position to be converted
ENTITY* Entity pointer

Returns:

VECTOR*

Modifies:

VECTOR*

Speed:

Medium

Remarks

For converting a normal vector to or from entity coordinates, the vec_rotate and vec_rotateback functions can be used.

Example (lite-C):

// let a halo sprite float above the entities' head
function move_halo()
{
  you = me; // store the parent entity
  me = ent_create("halo.mdl",nullvector,NULL);
 	while(you && me)
  {
     vec_set(my.pan,your.pan);
     vec_set(my.scale,your.scale);
     vec_set(my.x,vector(0,0,100)); // let the halo float 100 units about the entity center
     vec_for_ent(my.x,you); // convert the position to world coordinates
     wait(1);
  }
  if (you) ent_remove(you);
} 

See also:

ent_vertices, vec_for_normal, vec_for_mesh, vec_for_min, vec_for_vertex, normal_for_ent

► latest version online