
Capsule movemet Matrix
Re: Capsule movemet Matrix
I'm given up
, I'm understand what your talking about but I can't convert it to my code (little experience)

Re: Capsule movemet Matrix
If it's an issue of finding the forward/right vectors, it's just a matter of converting the orientation to a matrix, as I mentioned:
Note that in the above, the forward.Y is set to zero and then normalized because the old view matrix used previously could have a pitch component. If you know the playerQuaternion does not contain a pitch component, then you don't need to do the forward.Y = 0 and subsequent normalization.
Code: Select all
Matrix orientationMatrix = Matrix.CreateFromQuaternion(playerQuaternion);
Vector3 forward = orientationMatrix.Forward;
forward.Y = 0;
forward.Normalize();
Vector3 right = orientationMatrix.Right;
totalMovement += gamePadInput.ThumbSticks.Left.Y * new Vector2(forward.X, forward.Z);
totalMovement += gamePadInput.ThumbSticks.Left.X * new Vector2(right.X, right.Z);
CharacterController.MovementDirection = Vector2.Normalize(totalMovement);
Re: Capsule movemet Matrix
and what is "CharacterController.MovementDirection"
Re: Capsule movemet Matrix
That's just the direction in which the character tries to move.
You don't have to use every bit of that approach. If you just want to add in velocity along a single direction, like along orientationMatrix.Right, then you can just use playerCapsule.LinearVelocity += orientationMatrix.Right * acceleration.
You don't have to use every bit of that approach. If you just want to add in velocity along a single direction, like along orientationMatrix.Right, then you can just use playerCapsule.LinearVelocity += orientationMatrix.Right * acceleration.
Re: Capsule movemet Matrix
thanx alot Norbo (finally it works )
if any one need to know how it works, here it's:
Matrix orientationMatrix = Matrix.CreateFromQuaternion(playerQuaternion);
Vector3 forward = orientationMatrix.Forward;
forward.Y = 0;
forward.Normalize();
Vector3 right = orientationMatrix.Right;
playerCapsule.LinearVelocity -= orientationMatrix.Forward*padState.ThumbSticks.Left.Y*5;
playerCapsule.LinearVelocity -= orientationMatrix.Right * padState.ThumbSticks.Left.X * 5;
playerCapsule.LinearVelocity += new Vector3(0, -10, 0);
playerCapsule.LinearDamping =0.5f;
playerRotationY -= padState.ThumbSticks.Right.X * MathHelper.ToRadians(2f);
playerQuaternion = Quaternion.CreateFromAxisAngle(Vector3.Up, playerRotationY);
playerPosition = playerCapsule.Position - new Vector3(0, 50, 0);
playerCapsule.Orientation = playerQuaternion;
playerAnimator.World =Matrix.CreateScale(0.5f)*Matrix.CreateFromQuaternion(playerQuaternion) *Matrix.CreateTranslation(playerPosition);
My teacher we will continue in another Discussion (there is many thing I want to know
)

if any one need to know how it works, here it's:
Matrix orientationMatrix = Matrix.CreateFromQuaternion(playerQuaternion);
Vector3 forward = orientationMatrix.Forward;
forward.Y = 0;
forward.Normalize();
Vector3 right = orientationMatrix.Right;
playerCapsule.LinearVelocity -= orientationMatrix.Forward*padState.ThumbSticks.Left.Y*5;
playerCapsule.LinearVelocity -= orientationMatrix.Right * padState.ThumbSticks.Left.X * 5;
playerCapsule.LinearVelocity += new Vector3(0, -10, 0);
playerCapsule.LinearDamping =0.5f;
playerRotationY -= padState.ThumbSticks.Right.X * MathHelper.ToRadians(2f);
playerQuaternion = Quaternion.CreateFromAxisAngle(Vector3.Up, playerRotationY);
playerPosition = playerCapsule.Position - new Vector3(0, 50, 0);
playerCapsule.Orientation = playerQuaternion;
playerAnimator.World =Matrix.CreateScale(0.5f)*Matrix.CreateFromQuaternion(playerQuaternion) *Matrix.CreateTranslation(playerPosition);
My teacher we will continue in another Discussion (there is many thing I want to know
