# 2.5D platformer with gravity shifting

I'm using Unity to make a 2.5D action-platformer (3D graphics on a 2D plane) that utilizes gravity shifting as its main game mechanic; the idea is to be able to make any of the cardinal directions "down" and have the player be able to move like a normal platformer relative to the current gravity direction. I already have the gravity shifting down, but I keep running into issues with the player movement and camera. Currently the player movement works fine on the ground and ceiling ("south" and "north", respectively), but the camera isn't turning smoothly with the player for "north"; and the player is rotating along the world y-axis instead of its local y-axis "east" or "west" (also the camera doesn't rotate when shifting to these two directions).

I'm sure that the mistake(s) I'm making is/are small and easily fixed, but I keep coming up with 'solutions' that just cause other problems

``````float lLx = Input.GetAxis("LStickX");
float lLy = Input.GetAxis("LStickY");

if (lLx != 0)
{
if (lLx < 0)
{
mTargetTurnAngle = 90f;
}
else
{
mTargetTurnAngle = -90f;
}
transform.position += mMovementVector * (lLx * mMovementSpeed);
//mRb.AddForce(transform.right * (lLx * mMovementSpeed), ForceMode.Force);
transform.position = new Vector3(transform.position.x, transform.position.y, 0);
}

switch ((int)mCurGravity)
{
case 0: //South (normal gravity)
mGravNormal = Vector3.down;
mMovementVector = Vector3.right;
mTargetShiftAngle = 0f;
break;
case 1: //West
mGravNormal = Vector3.left;
mMovementVector = Vector3.down;
mTargetShiftAngle = -90f;
break;
case 2: //North
mGravNormal = Vector3.up;
mMovementVector = Vector3.left;
mTargetShiftAngle = 180f;
break;
case 3: //East
mGravNormal = Vector3.right;
mMovementVector = Vector3.up;
mTargetShiftAngle = 90f;
break;
default:
break;
}

if (mTargetShiftAngle != transform.rotation.eulerAngles.z || transform.rotation.eulerAngles.y != mTargetTurnAngle)
{
mTargetRotation = Quaternion.Euler(mTargetShiftAngle, mTargetTurnAngle, 0);
transform.rotation = Quaternion.RotateTowards(transform.rotation, mTargetRotation, mShiftRotatationSpeed);
Vector3 temp = transform.rotation.eulerAngles;
mCamera.transform.rotation = Quaternion.Euler(0, 0, temp.z);
//mCamera.transform.rotation = Quaternion.Euler(0, 0, temp.x);
}
mCamera.transform.position = new Vector3(transform.position.x, transform.position.y, -10);
.
.
.
if (Input.GetButtonDown("AButton"))
{
if (IsGrounded())
{