Hi, at the moment I'm trying to set up a decent collision system for my 3D fighting game, but for some reason I can't get trace() to work the way it should. It's the first time I've really messed around with trace(), so I'm probably doing something dumb. Anyway, what I want to do is this: when my character hits the punch button, he sends out a trace: if the trace hits another character, then it should check the distance between the centre of MY and YOU (becaue the bounding box isn't accurate enough), and the YOU character should play his "get hit" animation. So this is what I have, called when the player-character punches:
var attack_height;
var detect_hit;
define __hit,flag7;
code:
function forward_attack()
{
vec_set(detect_hit,my.x);
detect_hit.x+=400;//detect 400 quants ahead of character
vec_set(attack_height,my.x);
//attack_height.z+=my.max_z/2;
//(I was trying to send the trace from 3/4 up the character's height)
trace_mode=ignore_me;
//trace(attack_height,detect_hit);
//if(result != 0)
//(the above two lines didn't work either)
if (trace(attack_height,detect_hit) != 0)
{
if(you==enemy)//the synonym of the other player in the game is "enemy"
{
if(vec_dist(my.x,you.x)<340)
{you.__hit=on;}
}
}
return;
}
In both character's main function is this code:
code:
if (my.__hit==on)
{
my._movemode=_hitface_mode;
my._animdist=0;
}
if I replace "if (my.__hit==on)" with "if (key_p==1)", for instance, the hit animation plays fine. Likewise I know that the trace is being called... And yet nothing at all is happening.
If anyone can tell me what I'm doing wrong, I'd be really grateful (as usual).
Cheers,
Keith