Hi, and thanks for the quick and helpful response
I am using the standard character controller. To integrate it into my game, I had to make some very minor changes - namely, modify the input logic to use a CharacterInputState struct which is prepared externally rather than reading keyboard input directly. I'll paste it here so you can see what I mean and perhaps consider a similar pattern in the future because it helps with the task of integration.
Code: Select all
/// <summary>
/// This is used to keep track of the requested character input state.
/// </summary>
public struct CharacterInputState
{
[Flags]
public enum InputFlagTypes : byte
{
Forward = 1,
Backward = 1<<1,
Left = 1 << 2,
Right = 1 << 3,
Crouch = 1 << 4,
Jump = 1 << 5
}
public InputFlagTypes InputFlags;
}
And down below..
Code: Select all
//Collect the movement impulses.
Vector3 movementDir;
var flags = inputState.InputFlags;
Matrix mat;
cameraController.Camera.GetInvWorldMatrix(out mat);
if ((flags & CharacterInputState.InputFlagTypes.Forward) != 0)
{
movementDir = mat.Forward;
totalMovement += Vector2.Normalize(new Vector2(movementDir.X, movementDir.Z));
}
if ((flags & CharacterInputState.InputFlagTypes.Backward) != 0)
{
movementDir = mat.Forward;
totalMovement -= Vector2.Normalize(new Vector2(movementDir.X, movementDir.Z));
}
if ((flags & CharacterInputState.InputFlagTypes.Left) != 0)
{
movementDir = mat.Left;
totalMovement += Vector2.Normalize(new Vector2(movementDir.X, movementDir.Z));
}
if ((flags & CharacterInputState.InputFlagTypes.Right) != 0)
{
movementDir = mat.Right;
totalMovement += Vector2.Normalize(new Vector2(movementDir.X, movementDir.Z));
}
if (totalMovement == Vector2.Zero)
CharacterController.HorizontalMotionConstraint.MovementDirection = Vector2.Zero;
else
CharacterController.HorizontalMotionConstraint.MovementDirection = Vector2.Normalize(totalMovement);
CharacterController.StanceManager.DesiredStance = (flags & CharacterInputState.InputFlagTypes.Crouch) != 0 ? Stance.Crouching : Stance.Standing;
//Jumping
if ((flags & CharacterInputState.InputFlagTypes.Jump) != 0)
{
CharacterController.Jump();
}
Anyway, back to the problem. I should mention I am using my own Collidable here. I am working on a voxel based game where a 3d array of voxels are managed by a single Collidable because I understand this is the best way to get the most performance in that situation. It's implemented, seems efficient, and works as far as I can tell. It has been providing correct ray casting results for some time now, but I am just now starting to test the rest of the physics. It seems to be mostly working with little things like this coming up. So far the problems have been my fault, and I wouldn't be surprised if my trouble is my own doing here.
That being said, it was 100% reproducible. I'll grab your update, see how it affects it and let you know what I find out. Thanks for your time!