Simple character controller with skinned model

Discuss any questions about BEPUphysics or problems encountered.
limeh
Posts: 30
Joined: Sat Apr 30, 2011 7:22 pm

Re: Simple character controller with skinned model

Post by limeh »

alright! thanks norbo! got it to work already =)
limeh
Posts: 30
Joined: Sat Apr 30, 2011 7:22 pm

Re: Simple character controller with skinned model

Post by limeh »

eh just wondering is it possible to make it detect if the person is hit from the back? Cause i got 2 different animation, 1 for hit in the front, 1 for hit from the back
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Simple character controller with skinned model

Post by Norbo »

You could analyze the hit location/normal relative to the character's 'facing angle' (not included in the SimpleCharacterController itself, usually controlled by the camera or something).

Here's one option:

Code: Select all

if(Vector3.Dot((hitLocation - character.Body.Position), lookDirection) < 0))
       DoGotHitOnTheBack(); 
limeh
Posts: 30
Joined: Sat Apr 30, 2011 7:22 pm

Re: Simple character controller with skinned model

Post by limeh »

what would the lookDirection be like? is it an angle of -180 to 180 or would it be a value of -3 to 3 (like the camera yaw)

Also, how do i actually change the orientation of my collision box (capsule in simplecharactercontroller) based on my camera yaw?
I've tried to apply a Matrix.CreateRotationY(camera.yaw) into my Body.WorldTransform . For some reason, the rotation doesn't work. It works on other axis such as X and Z but it just doesn't work on Y. I've checked the values and yes the values are being changed. but not the capsule (based on the collision box drawn using linedrawer)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Simple character controller with skinned model

Post by Norbo »

what would the lookDirection be like? is it an angle of -180 to 180 or would it be a value of -3 to 3 (like the camera yaw)
It's not an angle. The dot product takes two vectors. The lookDirection is a direction vector pointing in the direction that your camera is looking.
Also, how do i actually change the orientation of my collision box (capsule in simplecharactercontroller) based on my camera yaw?
I've tried to apply a Matrix.CreateRotationY(camera.yaw) into my Body.WorldTransform . For some reason, the rotation doesn't work. It works on other axis such as X and Z but it just doesn't work on Y. I've checked the values and yes the values are being changed. but not the capsule (based on the collision box drawn using linedrawer)
That collision box is an AABB. It is an axis aligned box which contains whatever shape is inside. Rotating a capsule around its local Y axis does not change the bounding box, because the extreme points along X, Y, and Z do not change.

Also, I recommend that you not change the orientation of the character. Handling all camera viewing/gameplay character orientation stuff external to the physics will prevent some pain.
limeh
Posts: 30
Joined: Sat Apr 30, 2011 7:22 pm

Re: Simple character controller with skinned model

Post by limeh »

How do i change the shape of the collision box as you have suggested? I tried changing the length but that causes certain problem on the simple character controller. Again, i'm trying to simulate the falling state.. Just need to reduce the height to a much smaller one
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Simple character controller with skinned model

Post by Norbo »

How do i change the shape of the collision box as you have suggested? I tried changing the length but that causes certain problem on the simple character controller. Again, i'm trying to simulate the falling state.. Just need to reduce the height to a much smaller one
If you want the bounding box of the character to be smaller, the character body must be smaller. The character controller would need to be modified to handle the changes. Modifying the character controller in such a way is doable, but it is certainly easier to just not do it.

Another option than actually changing the character controller is to have two different character controllers which are used based on what state the character is in. You would have to manage the transition to make sure it ended up smooth.
limeh
Posts: 30
Joined: Sat Apr 30, 2011 7:22 pm

Re: Simple character controller with skinned model

Post by limeh »

I'm using this for changing of the length..
if (Mage.currentState == 15)
{
MageCollisionBox.Body.Length = 0.5F;
}
else
{
MageCollisionBox.Body.Length = 3.2F;
}

This works except that the body bounding box will end up rotating weirdly after the change of length happens.
Using 2 different character controllers seem possible but how do i disable the first one after i activate the 2nd one in the state? Or do i just disable any collision with the 1st shape?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Simple character controller with skinned model

Post by Norbo »

This works except that the body bounding box will end up rotating weirdly after the change of length happens.
The AABB cannot rotate; it is axis aligned. Something else is probably going on. Expansion/contraction is normal, however, since it has to contain the increased or decreased length. The main problem will be that the character controller's other settings need to be modified (like the support casting origin and such).
Using 2 different character controllers seem possible but how do i disable the first one after i activate the 2nd one in the state? Or do i just disable any collision with the 1st shape?
You could disable collision, or just remove it from the space entirely.
Post Reply