Example #1
0
    public override void GetMoveVectors(Vector3 upVector, out Vector3 forward, out Vector3 right)
    {
        Transform importantT = myCamera.transform;

        if (pc.gravityApplication != MovingEntity.GravityState.none)
        {
            Vector3 generalDir = importantT.forward;
            if (importantT.forward == upVector)
            {
                generalDir = -importantT.up;
            }
            else if (importantT.forward == -upVector)
            {
                generalDir = importantT.up;
            }
            MovingEntity.CalculatePlanarMoveVectors(generalDir, upVector, out forward, out right);
            if (currentPitch > 90)
            {
                right *= -1; forward *= -1;
            }                                                                 // if we're upside-down, flip to keep it consistent
        }
        else
        {
            right = importantT.right; forward = importantT.forward;
        }
    }