Character Controller Movement - Different speeds on different axis

Hi.

I’m basically trying to modify and simplify the standard Character Controller script given by Unity with the Standard Assets. The problem is that the character used the same walking speed for forward walking and side walking, but I want the side walking speed to be slower.

.

Currently it’s moving speed is faster with the Z-axis and slower with the X-axis, the problem is that it’s using the global axis, so no matter which way I turn my character it will always have those speeds in those specific directions. I want the axis to follow the rotation of my character so the different walking speeds are relative to it and not the world.

.

I tried some stuff but like converting to local vectors but it only gave Jittery movement or wrong input directions.

.

Hope somebody can help. Thanks in advance.

private void FixedUpdate()
    {
        GetInput(out speed);

        //Always move along the camera forward as it is the direction that it being aimed at
        Vector3 desiredMove = transform.forward * TheInput.y + transform.right * TheInput.x;

        MoveDir.x = desiredMove.x * SideWalkSpeed;
        MoveDir.z = desiredMove.z * ForwardWalkspeed;

       CharacterController.Move(MoveDir * Time.fixedDeltaTime);  }

Should be as simple as that:

	private void FixedUpdate()
	{
		GetInput(out speed);

		//Always move along the camera forward as it is the direction that it being aimed at
		MoveDir = transform.forward * TheInput.y * ForwardWalkspeed + transform.right * TheInput.x * SideWalkSpeed;

		CharacterController.Move(MoveDir * Time.fixedDeltaTime);  }