Page 1 of 1

Head Shot

Posted: Thu Jul 16, 2009 6:44 pm
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

Re: Head Shot

Posted: Thu Jul 16, 2009 6:48 pm
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.

Re: Head Shot

Posted: Thu Jul 16, 2009 6:50 pm
by Norbo
After the initial detection, you could also just raycast some other structure, like your own mesh representation.

Re: Head Shot

Posted: Thu Jul 16, 2009 6:58 pm
by BoltonBeedz
Great.. But.. The ray needs to pass through the capsule in the event that the player misses the detail object.

Re: Head Shot

Posted: Thu Jul 16, 2009 6:59 pm
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.

Re: Head Shot

Posted: Thu Jul 16, 2009 7:14 pm
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..