some vec_dist problems

Posted By: onslaught147

some vec_dist problems - 11/06/08 02:18

i have multiple copies of a entity and i need them to calculate the distance between each other but when i do vec_dist(me.x,entity.x) it returns zero because its calculated the dist from itself to itself. so how do i make the vec_dist look to other types of the same entity with the exact ssame name but only use its own position for the me.x portion of the equation?
Posted By: onslaught147

Re: some vec_dist problems - 11/06/08 07:01

another question i have, it falls into the same category as the one above. i have several enemies and guns all called the same things. they are just copies of the original enemy and gun, but when i do vec_for_vertex(gun.x,enemy,#num) it makes the first made gun attach to the first made enemy. how do i make one gun attach to one entity for all my many copies no matter when they were made?
Posted By: delinkx

Re: some vec_dist problems - 11/06/08 07:35

y use the same name. Give unique index names for each entity. easier to control.
Posted By: onslaught147

Re: some vec_dist problems - 11/06/08 22:33

i cant give them seperate names because its the same. i dont think u understand what i am askin. if i had one enemy and one gun it works perfectly fine. but if i copy it, the code still only works for the first enemy and gun and ignores the second pair. the second pair still moves and preforms there code but the vec_for_vertex is only set for the first pair. if i made different names i would have to copy the script in game which will be a problem whenever i want to change code because i will have to do that multiple times. so thanks for the responce but it doesnt really help. or i may miss interpret wat ur tryin to say and if tats the case u or someone else please elaborate
Posted By: DJBMASTER

Re: some vec_dist problems - 11/06/08 22:38

use entity pointers.

ENTITY* num_1;
ENTITY* num_2;
ENTITY* num_3;
ENTITY* num_4;

then assign them inside their actions...

action entity_1()
{
num_1 = me;
}

or if you don't want actions, create them using pointers...

num_1 = ent_create("model.mdl",vector(0,0,0),NULL);
Posted By: onslaught147

Re: some vec_dist problems - 11/06/08 23:35

how would i do
action entity_1()
{
num_1 = me;
}

if they all use the same script, tat will just make all of them be num_1 and the engine only using the first entity of the same name is my problem in the first place, am i screwed and just have to do the same code multiple times just to name each entity differently.
© 2024 lite-C Forums