3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
how to get the bonename from c_trace ?
#474653
10/27/18 14:55
10/27/18 14:55
|
Joined: Oct 2018
Posts: 10
Anewbie
OP
Newbie
|
OP
Newbie
Joined: Oct 2018
Posts: 10
|
I am trying to get the name of the limbs that are shot by the player in my game. I tried this by checking the old threads of this forum :
draw_text ("active", 10,10, vector(255,0,0)); var sight = 300; VECTOR tpos; STRING* bonename="empty"; vec_for_angle (tpos, vector (my.pan, my.tilt, my.roll)); vec_scale (tpos, sight); vec_add (tpos, vector (my.x, my.y, my.z)); trace_mode = IGNORE_ME | IGNORE_PASSABLE | USE_BOX | SCAN_TEXTURE | IGNORE_SPRITES; c_ignore (1, 0); c_trace (vector (my.x, my.y, my.z), tpos, trace_mode); draw_point3d (target.x,vector(50,50,255),100,3); if(you && hit){ ent_bonename (you, bonename, hit.vertex); draw_text (bonename, 10, 20, vector (255,0,0)); }
However it always shows the same bone name which is the left foot. I am using a non animated t-posing model for testing. I also would like to know how to check all the names of the bones of a model in MED. Thanks!
|
|
|
Re: how to get the bonename from c_trace ?
[Re: Anewbie]
#474655
10/27/18 15:25
10/27/18 15:25
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Hi there! a quote from the manual: For detecting which limb of an actor entity was hit, use the vertex number from the hit struct and retrieve the bone name with the ent_bonename function. Take a look here: c_trace ent_bonename Edit: gonna make an example, please wait Edit2: please, take a look at this example (used guard model from my contribution):
#include <acknex.h>
#include <default.c>
#define PRAGMA_POINTER
void main(){
warn_level = 6;
fps_max = 60;
level_load("");
vec_set(&camera->x, vector(152, 0, 43));
vec_set(&camera->pan, vector(180, -15, 0));
def_move();
ENTITY *guard_ent = ent_create("guard.mdl", nullvector, NULL);
set(guard_ent, POLYGON);
while(guard_ent){
VECTOR temp;
vec_set(&temp, vector(1024, 0, 0));
vec_rotate(&temp, &camera->pan);
vec_add(&temp, &camera->x);
draw_point3d(&temp, COLOR_RED, 100, 4);
c_trace(&camera->x, &temp, IGNORE_PASSABLE | SCAN_TEXTURE);
if(trace_hit){
draw_point3d(&hit->x, COLOR_RED, 100, 4);
if(you){
STRING *bone_name_str = "";
ent_bonename(you, bone_name_str, hit->vertex);
draw_text(bone_name_str, 10, 40, COLOR_WHITE);
DEBUG_VAR(hit->vertex, 10);
}
}
wait(1);
}
}
It will display the bone, closest to the 'hit.x' position. Edit3: if you want to check, which limb was hit (f.e. wanted to create hitboxes or such, to detect headshots etc), I would suggest you to use Superku's solution. You can find it in AUM 103, here. It's going to be faster. Greets!
|
|
|
Re: how to get the bonename from c_trace ?
[Re: 3run]
#474656
10/27/18 15:46
10/27/18 15:46
|
Joined: Oct 2018
Posts: 10
Anewbie
OP
Newbie
|
OP
Newbie
Joined: Oct 2018
Posts: 10
|
Hi there! a quote from the manual: For detecting which limb of an actor entity was hit, use the vertex number from the hit struct and retrieve the bone name with the ent_bonename function. Take a look here: c_trace ent_bonename Edit: gonna make an example, please wait Edit2: please, take a look at this example (used guard model from my contribution):
#include <acknex.h>
#include <default.c>
#define PRAGMA_POINTER
void main(){
warn_level = 6;
fps_max = 60;
level_load("");
vec_set(&camera->x, vector(152, 0, 43));
vec_set(&camera->pan, vector(180, -15, 0));
def_move();
ENTITY *guard_ent = ent_create("guard.mdl", nullvector, NULL);
set(guard_ent, POLYGON);
while(guard_ent){
VECTOR temp;
vec_set(&temp, vector(1024, 0, 0));
vec_rotate(&temp, &camera->pan);
vec_add(&temp, &camera->x);
draw_point3d(&temp, COLOR_RED, 100, 4);
c_trace(&camera->x, &temp, IGNORE_PASSABLE | SCAN_TEXTURE);
if(trace_hit){
draw_point3d(&hit->x, COLOR_RED, 100, 4);
if(you){
STRING *bone_name_str = "";
ent_bonename(you, bone_name_str, hit->vertex);
draw_text(bone_name_str, 10, 40, COLOR_WHITE);
DEBUG_VAR(hit->vertex, 10);
}
}
wait(1);
}
}
It will display the bone, closest to the 'hit.x' position. Edit3: if you want to check, which limb was hit (f.e. wanted to create hitboxes or such, to detect headshots etc), I would suggest you to use Superku's solution. You can find it in AUM 103, here. It's going to be faster. Greets! Thanks a lot ! Turns out that i forgot to set the POLYGON flag. That is why it was always showing the same bone.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|