Animated Collision Detection
by Tony Pitman · in Torque X 3D · 06/16/2010 (11:20 am) · 3 replies
I am going to do an updated Zombie Sniper 3D. It will be a sequel. One of the things that we will be doing better is the animation. This introduces a problem, however.
In ZS3D The user is pointing a gun at the zombies. I needed to detect whether the site was on the head or the body. I use RayCast to do this. The problem is that I wasn't able to hit test against the zombie model because the bounding box covers the whole zombie including space around him that doesn't even have any model parts. I also couldn't figure out a good way to tell whether it was the head or the body.
So what I did was made the animation very stiff. It just goes up and down as he walks. I then mounted 2 spheres...one in the head and one in the body. They are both invisible, but RayCast does detect them. I then move the sphere's relative positions based on the current frame in the animation. I thought this was pretty ingenius. It works really well such as it is.
Now I want to have much better animations. I want variety and up / down and side to side movement. I also would like to detect ANY hit on the zombie anywhere. I will still need to tell if it is a head or body shot. It would be even better if I could detect a hit on a finger and blow the finger off and that sort of thing.
The question is HOW?
In ZS3D The user is pointing a gun at the zombies. I needed to detect whether the site was on the head or the body. I use RayCast to do this. The problem is that I wasn't able to hit test against the zombie model because the bounding box covers the whole zombie including space around him that doesn't even have any model parts. I also couldn't figure out a good way to tell whether it was the head or the body.
So what I did was made the animation very stiff. It just goes up and down as he walks. I then mounted 2 spheres...one in the head and one in the body. They are both invisible, but RayCast does detect them. I then move the sphere's relative positions based on the current frame in the animation. I thought this was pretty ingenius. It works really well such as it is.
Now I want to have much better animations. I want variety and up / down and side to side movement. I also would like to detect ANY hit on the zombie anywhere. I will still need to tell if it is a head or body shot. It would be even better if I could detect a hit on a finger and blow the finger off and that sort of thing.
The question is HOW?
#2
06/17/2010 (10:05 pm)
I think what you have to do is create a master object, like the torso, then make the arms, head, legs all sub objects mounted to the torso. Each object and sub object would have to have their own collision detection. You would also get the added benefit of being able to shoot off the mounted objects. Or for even more fun, say the arm is shot you could replace the arm with a wiggly bloody stump.
#3
The biggest issue here, however, is the animation then. Does anyone know of a good ragdoll animation engine that I can make my own parts for that will work in Torque X?
06/17/2010 (10:10 pm)
I was thinking about this as an option too.The biggest issue here, however, is the animation then. Does anyone know of a good ragdoll animation engine that I can make my own parts for that will work in Torque X?
Torque Owner Tony Pitman
Default Studio Name
I would like to know if there is a way to RayCast against individual meshes. My thought is if instead of a single mesh that gets animated I could have my new 3D guy make a model that is made up of many meshes. A mesh for the head and one for the body and legs and so forth.
I could then do a rough RayCast that checks for hits on the main bounding box of a zombie. Since that bounding box covers the whole thing and not just the actual zombie I would then need a way to hit test on individual meshes inside the zombie object.
This would also fix the problem with animation because instead of the animation working on the meshes vertices like my current zombie, the parts of the zombie would animate.
So the question is this: is there a way to RayCast against meshes inside of the main model object?