Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 803 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trace() problems - please help! #5432
07/10/01 03:05
07/10/01 03:05
Joined: Mar 2001
Posts: 1,825
London, England
Keith B [Ambit] Offline OP
Expert
Keith B [Ambit]  Offline OP
Expert

Joined: Mar 2001
Posts: 1,825
London, England
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


Re: Trace() problems - please help! #5433
07/10/01 20:08
07/10/01 20:08
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
You need vectors, so:

var ...[3]; !!

And this line is wrong:

detect_hit.x+=400;//detect 400 quants ahead of character

You are tracing into the wrong direction - always in X direction but the enemy can be everywhere! You must rotate the vector before:

temp.x = 400;
temp.y = 0;
temp.z = 0;
vec_rotate(temp,my.pan);
vec_add(detect_hit, temp);

understand what I mean?


Re: Trace() problems - please help! #5434
07/10/01 22:37
07/10/01 22:37
Joined: Mar 2001
Posts: 1,825
London, England
Keith B [Ambit] Offline OP
Expert
Keith B [Ambit]  Offline OP
Expert

Joined: Mar 2001
Posts: 1,825
London, England
Hi, Tobias, thanks for the reply. I figured out that I'd forgot to use a vector, but I hadn't realised about the pan etc - I'd thought it was automatically adjusted to the my, so that'll be where I was going wrong.

Thanks again, that helps a lot.
Cheers
Keith



Moderated by  HeelX, Spirit 

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