Head Shot

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
BoltonBeedz
Posts: 45
Joined: Fri Dec 07, 2007 12:58 am

Head Shot

Post by BoltonBeedz »

Hi. This will probably sound thick but I'm looking for a bit of help if anyones not busy.
I'm trying to get a good head shot on a "skinned" model with a sniper rifle. The problem being that I want the enemy to be a capsule generally, then when you shoot your player's gun, switch to a compound body for purpose of a ray cast. Is there an easy or powerful way to do this or should i


1: remove capsule from space
2: add compound to space
3: pose compound at the capsule's position
3: ray cast
4: remove compound from space
5: add capsule to space

I wonder if this would cause partitioning overhead?
Er. Anyone know about this thing here that I just said?

Cheers
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Head Shot

Post by Norbo »

You could use an outer shape (such as the capsule itself) that fully contains the player's limbs, head and torso to detect the initial raycast. Then, test against a separate set of 'body' entities.

You'd need to set up some shapes that represent the character's body (or at least the shootable parts). These don't need to be in the space since you can call an entity's rayTest function without using space.rayCast or the entity even belonging to a space. When the outer shape detects the initial raycast, you'd then perform a rayTest on the more detailed 'body' entities to see what part, if any, was hit.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Head Shot

Post by Norbo »

After the initial detection, you could also just raycast some other structure, like your own mesh representation.
BoltonBeedz
Posts: 45
Joined: Fri Dec 07, 2007 12:58 am

Re: Head Shot

Post by BoltonBeedz »

Great.. But.. The ray needs to pass through the capsule in the event that the player misses the detail object.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Head Shot

Post by Norbo »

There is an overload of the Space.rayCast method that returns every hit along the ray up to a maximum distance. Using it will allow the ray to continue.
BoltonBeedz
Posts: 45
Joined: Fri Dec 07, 2007 12:58 am

Re: Head Shot

Post by BoltonBeedz »

Yowzer.
Let me get this straight. I need to to run through List<float>tois until I hit the an enemies capsule then pose, ray cast outside of space. I like the cut of your jib Norbo. That allows me to do the stuff I asked about at the top there. Thanks again..
Post Reply