Game Development Community

Help With Hitboxes

by Shawn Simas · in Torque Game Engine · 09/04/2004 (2:22 pm) · 10 replies

I've seen a couple hitbox resources around, but I didn't particularily like how they were done.

I decided I'd rather build the hitboxes into the player.dts as collision meshes. I've already increased the max meshes up to allow for a much better number of hitboxes, but... I've come to another problem.

Now, I've thought of two ways this could be done - one which seems easier than the other.

The easier method would be to go into ShapeBase::onCollision and use the point it is passed and test to see which collision mesh(es) its within.
Where I'm stuck with this method is I don't know how to access the collision shape data(to build a box out of it for testing). I also don't know how I'd test it yet since I'm not super math - but I could look into that... getting the information is a little more important right now

The other way I thought about was to just have Torque use my hitboxes instead of the collision mesh that is automatically generated for the player. I'd still want it to use that auto one for things like checking player against terrain, but use mine for melee weapons and projectiles...
My problem here is I have no idea where to even begin to attempt this!

So, any help would be greatly appreciated, even if its just pointing me in the right direction!

Shawn

#1
09/06/2004 (12:13 pm)
Do a raycast against the appropriate TSMesh instances? You'll find a TSShapeInstance pointer somewhere in the player, which you can dig through to get to TSMeshes by name. (findNode.) Then you can cast rays against them, which should get you what you want. Might be able to check if a point is inside them, too.
#2
09/07/2004 (5:41 am)
I suggest you to look at how the Player::RayCast works, go deep inside it and you'll find the answer !! Ok, that was I did, and I find a solution, now I have unlimited hit boxes, but I haven't used the collision mesh, because it seems to me that they aren't animated correctly, they were animated only around the origin, don't know if in the latest head this has been fixed, or if I haven't understood well them, anyways, the simplest solution form me was to add new boxes like a normal mesh, used a standard name like HB** to find them in the code, make them invisible and ... done! torque has all the functions needed to test the interesection of a ray against a mesh, just remember that the mesh must be convex.
I thought to create a resource for this, but, first, I haven't the time, second perhaps this isn't the best way of doing it, using the collision meshes should be the right way
#3
09/07/2004 (10:12 am)
Well Davide - post what you got as a resource. I for one would like to see it, as I need to hack into this for our game. Even if it isnt cleaned up, it might save me an hour or two.

Please?
#4
09/13/2004 (12:14 pm)
Ok, I've received the permission to share the hitbox collision code, so I'll create a resource for it, but as I said, I haven't much time so you have to be patient. I'll do my best :)
#5
09/13/2004 (1:01 pm)
Cool! I'd love to see this resource... please post a link here when you get it up!
#6
09/20/2004 (10:31 am)
Any news on this yet? :D

I've been lookin for something like this forever.
#7
09/20/2004 (1:04 pm)
I'm writing the resource, I think I need at least another week, not much time last week :(
#8
10/08/2004 (12:59 pm)
Ok, sorry I'm on late :) but the resourse is up, you can find it here
#9
10/08/2004 (2:13 pm)
@Davide
Is this only for the player ?
Or can i have a HB box on a sword should this work ?
#10
10/09/2004 (5:00 am)
If you want to create a sword that, for example, can be destroyed when hit by a projectile, yes with this resource you can do also this, I've already done it for a shield item mounted on the player. If you mean to use the hitbox to find when the sword hits something, this isn't possible with this resource.