hit vertex

Posted By: Reconnoiter

hit vertex - 01/28/15 00:40

Hi,

I want to let a projectile stick to an enemy after it hit. So I want to use hit.vertex (hit.x is not accurate enough) to get the nearest vertex and since I can't get it from a c_move collision event I use a c_trace after the c_move collision. But it doesn't pick the right vertex of the enemy, it always picks the same vertex of the enemy no matter where I hit the enemy.

Code:
...projectile hits enemy through c_move...
if (HIT_TARGET)
{
 if (you)
 {
  enemy_p = you;

  VECTOR tmpfrom_vec, tmpto_vec;
  vec_set(tmpfrom_vec, vector(my.x-(20)*cos(my.tilt)*cos(my.pan),my.y-(20)*cos(my.tilt)*sin(my.pan),my.z-(20)*sin(my.tilt)));
  vec_set(tmpto_vec, vector(my.x+(20)*cos(my.tilt)*cos(my.pan),my.y+(20)*cos(my.tilt)*sin(my.pan),my.z+(20)*sin(my.tilt))); 
  
  if(c_trace(tmpfrom_vec, tmpto_vec, IGNORE_PASSABLE | IGNORE_FLAG2) > 0)
  {
   if (you) 
   {
    if (enemy_p == you) vec_for_vertex (my.x, enemy_p, hit.vertex);	
   }
  }
....
 }
}
....



Don't see why this shouldn't get the right vertex crazy
Setting SCAN_TEXTURE for c_trace does also not seem to help.
Posted By: sivan

Re: hit vertex - 01/28/15 10:45

due to manual you must use SCAN_TEXTURE to get the vertex data, and imo IGNORE_ME too, because you use the me entity. and I normally use IGNORE_CONTENT.

but you use wrongly vec_for_vertex, the 3rd parameter is the vertex number, not the vertex struct
Posted By: Reconnoiter

Re: hit vertex - 01/28/15 17:09

huh but the manual says this about hit vertex confused :

Quote:

hit.vertex Vertex number closest to the contact. Can also be used to determine the hit limb of a bones animated model through the ent_bonename function.


Do I need to use ent_getvertex or something like that?
Posted By: Ch40zzC0d3r

Re: hit vertex - 01/28/15 18:28

Well, he uses it right but how do you know it doesnt work?
Add some debugging (for example some error's or beeps) and you know where exactly it stucks.
I bet you hit your ME entity and thats why if (enemy_p == you) fails.
Posted By: Reconnoiter

Re: hit vertex - 01/28/15 19:10

Thanks for taking the time.

I use ignore_me in the c_trace now as Sivan suggested but it has the same error. I have added 'you = NULL;' for testing purposes:

Code:
you = NULL;
if(c_trace(tmpfrom_vec, tmpto_vec, IGNORE_PASSABLE | IGNORE_FLAG2 | IGNORE_ME | IGNORE_CONTENT | SCAN_TEXTURE) > 0)
{
 if (you) 
 { 
  if (enemy_p == you) 
  { 
   vec_for_vertex (my.x, you, hit.vertex);
   debug_var1 = hit.vertex;	
  } 	
 }
}



The debug var shows always 39 (within my interface while loop: DEBUG_VAR(debug_var1, 400); ). Also the arrow is moved to some vertex (probably to 39, cause I have checked vertex 39 in the model editor and it seems to match the location).

Also tried 'ent_remove(you);' and that works so the you is valid. Same goes for 'ent_remove(my);' so my is also valid.

So I must be doing something wrong with hit.vertex., vec_for_vertex itself seems to be working right.
Posted By: Ch40zzC0d3r

Re: hit vertex - 01/28/15 19:19

Use USE_POLYGON in your trace
Posted By: Reconnoiter

Re: hit vertex - 01/28/15 20:01

That works, thanks man
© 2024 lite-C Forums