Simple character controller with skinned model
Re: Simple character controller with skinned model
alright! thanks norbo! got it to work already =)
Re: Simple character controller with skinned model
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
Re: Simple character controller with skinned model
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:
Here's one option:
Code: Select all
if(Vector3.Dot((hitLocation - character.Body.Position), lookDirection) < 0))
DoGotHitOnTheBack();
Re: Simple character controller with skinned model
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)
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)
Re: Simple character controller with skinned model
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.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)
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, 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)
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.
Re: Simple character controller with skinned model
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
Re: Simple character controller with skinned model
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.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
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.
Re: Simple character controller with skinned model
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?
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?
Re: Simple character controller with skinned model
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).This works except that the body bounding box will end up rotating weirdly after the change of length happens.
You could disable collision, or just remove it from the space entirely.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?