Game Development Community

dev|Pro Game Development Curriculum

HitBoxes For Players.

by Joshua "The Power Nap" Taylor · 03/11/2003 (1:41 pm) · 18 comments

Download Code File

Okay,

This is a starting point for alot of the features that I've added to the TGE. This code works with the 1.1.2 version.

Thanks goes to Josh Albrecht for getting me started. I gave credit for his code in the attached document.

If there is any problems PLEASE let me know. I want this to be a meaningfull contribution.

And BACK UP YOUR FILES! before you use this resource.

#1
03/11/2003 (3:14 pm)
What's the difference to Josh's code?
#2
03/11/2003 (3:55 pm)
This tutorial is JUST hitboxes,

In Josh's he added the hand-to-hand, melee, and projectile embedding.

In this resource, I implement the code in castRay. This takes advantage of the Torques OOD better, and cuts out any extra code that might be required by objects that interact with the player's hitboxes.

And last, I optimized a few things in how the boxes are checked, and set it up so you can get the exact point of impact on the hitboxes.

This resource is also a starting point for others I'll upload in the future.
#3
03/31/2003 (5:38 pm)
That's cool to see that someone built off of my code.

Actually, I've been meaning to break down the previous code to make it easier for other people to use, but it will take some serious time, and I am pressed for that right now. :)

Hopefully I'll get around to it soon.
#4
11/03/2003 (5:10 pm)
I implemented this and it 'works' but crashes the game. Debugging brings up the line

TEMP.max=nHitbox.lastLocation.max;

Any ideas? :S
#5
11/04/2003 (5:57 am)
Actually it seems like the problem is with the line below it.

trans.mul(getRenderTransform(),getNodeTransfor(nHitbox.nodeName));

getNodeTransfer didint exist, so i took it from Josh Albrecht's resource. Was I right to do this?

But in VC++ Debug after it crashed every property of nhtibox has no value, just the error: expression cannot be evaluated.

So where it uses nHotbox.lastLocation andnitbox.nodename its not getting any values...

It seems that Player::CheckHitBoxes is having huge problems, is it not gettin the hit box sent to it?
#6
11/04/2003 (7:35 am)
After goign through some more debugging i noticed that both collideWithHitBox and CheckHitBoxes have go no values for mHitboxes or nHitbox. Maybe these hitboxes are being initialized wrong :S
#7
11/06/2003 (8:49 pm)
Well,

It sounds like they arent' being updated. They should be updated in processTick and interpolateTick. That's where they get the values from the datablock.
#9
11/17/2003 (3:50 pm)
Ok heres a fix.

In player.h

PlayerData Class

change

U32 CheckPattern[3][NUMHITBOXES];

to

U32 CheckPattern[4][NUMHITBOXES];

In player.cc

PlayerData::PlayerData

after

CheckPattern[0][k] = temp1[k];
CheckPattern[1][k] = temp2[k];
CheckPattern[2][k] = temp3[k];

add

U32 temp4[10] = {0,1,3,2,5,4,7,6,9,8};

then below add

CheckPattern[4][k] = temp4[k];
#10
02/07/2004 (6:43 pm)
I give much props to both Josh's for their contributions on hit boxes. This resource here I found the easier of the two to follow and implement. The only problem I had was the same one Westy did and his code fixed it for me. Hooray.

I think I found a typo in the resource however.

In this line

Inside the Projectile::onCollision function add This after
if(!isServerObject())
return;

I believe should read

Inside the Projectile::onCollision function add This in this if statment
if (!isClientObject() && hitObject != NULL) {

Because the earlier if statment isn't in this function. Any ways thats what I did and it worked.

Thanks again for sharing the knowledge. It helps soooooo much.
#11
08/12/2004 (6:55 pm)
I just applied this but and it compiled fine, but when you try to walk or sidestep the animation doesnt play you just 'glide' along. But the idle and jump animations and the like work.

Now, I'm guessing I just implemented something wrong. but instead of starting all over I figured i'd ask here first.

If anyone can point me in the right direction I'd be more than happy, thanks!
#12
08/12/2004 (8:10 pm)
Hmm. I reimplemented the whole thing... but.. same problem, could it be with the newer HEAD this is causing a problem?
#13
08/12/2004 (9:11 pm)
Don't know what was wrong, but works now.
#14
11/24/2004 (7:20 pm)
Posted on wrong hitbox resource.
#15
11/13/2005 (7:48 am)
Has anyone used Josh's hitbox code with the soldier from Soldier Pack? Aside from a different bone/node naming convention (which I thought I had worked around), the soldier's hitboxes never register collisions. Any suggestions, hints, or problems you encountered would be greatly appreciated. Being the Ultimate Newbie, I'm never sure if it is a SUT (Stupid User Trick) or a real problem.

Thanks in advance for any help/insights.
#16
04/27/2006 (8:11 pm)
This resource is very problematic with current codebase as it stands, theres quite a few little things that need chaning to get it working.
#17
06/09/2006 (11:28 am)
Nice resource.
#18
08/26/2008 (5:52 am)
After compilation i did not get any error , but when i am hiting to aiplayer through the Crossbow projectile , this is nothing happen.I look the in projectile.cc file..

ShapeBase* p = dynamic_cast(hitObject);
if(p != NULL)
{
......
.....
}
Here p is assigning always NULL value.Therefore the function "onCollisionWithShapeBas" is not getting called.How will i fix the problem.