Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 972 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
hit vertex #448297
01/28/15 00:40
01/28/15 00:40
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
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.

Re: hit vertex [Re: Reconnoiter] #448305
01/28/15 10:45
01/28/15 10:45
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
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

Last edited by sivan; 01/28/15 10:49.

Free world editor for 3D Gamestudio: MapBuilder Editor
Re: hit vertex [Re: sivan] #448313
01/28/15 17:09
01/28/15 17:09
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
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?

Re: hit vertex [Re: Reconnoiter] #448314
01/28/15 18:28
01/28/15 18:28
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
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.

Re: hit vertex [Re: Ch40zzC0d3r] #448315
01/28/15 19:10
01/28/15 19:10
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
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.

Last edited by Reconnoiter; 01/28/15 19:13.
Re: hit vertex [Re: Reconnoiter] #448317
01/28/15 19:19
01/28/15 19:19
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Use USE_POLYGON in your trace

Re: hit vertex [Re: Ch40zzC0d3r] #448319
01/28/15 20:01
01/28/15 20:01
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
That works, thanks man


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1