Ejemplo n.º 1
0
    /*
     * ISSUES:
     * Why are we wiggling to one side or the other on the ground?
     *
     * If we're accurately moving on the ground, it seems to work great!
     * Down the road: wall collisions
     */
    private void CheckForGround3()
    {
        if (c_collisionController.CheckForGround4())
        {
            c_playerData.v_currentPosition += c_collisionData.v_attachPoint;

            c_accelMachine.Execute(Command.LAND);
            c_turnMachine.Execute(Command.LAND);
            c_airMachine.Execute(Command.LAND);
            sm_tricking.Execute(Command.LAND);
            sm_trickPhys.Execute(Command.LAND);
        }

        /*
         * Up next, the case that we're on the gorund, not IN it
         */
        else if (c_collisionController.CheckForAir())
        {
            c_playerData.v_currentPosition += c_collisionData.v_attachPoint;
            debugAccessor.DisplayVector3("attachpoint", Quaternion.Inverse(c_playerData.q_currentRotation) * c_collisionData.v_attachPoint);

            // if we hit the range where there's less than a "frame" of motion until the ground, we should still consider that landing
            c_accelMachine.Execute(Command.LAND);
            c_turnMachine.Execute(Command.LAND);
            c_airMachine.Execute(Command.LAND);
            sm_tricking.Execute(Command.LAND);
            sm_trickPhys.Execute(Command.LAND);
        }
        else
        {
            c_collisionData.v_attachPoint = Vector3.zero;

            c_accelMachine.Execute(Command.FALL);
            c_turnMachine.Execute(Command.FALL);
            c_airMachine.Execute(Command.FALL);
            sm_trickPhys.Execute(Command.FALL);
            sm_tricking.Execute(Command.READY_TRICK);
        }

        /*
         * else if (!c_collisionController.CheckForAir())
         * {
         *  debugAccessor.DisplayString("NOT DETECTIN'");
         *  debugAccessor.DisplayVector3("AIR CHECK AERIAL", Vector3.zero);
         *  c_collisionData.v_attachPoint = Vector3.zero;
         *
         *  c_accelMachine.Execute(Command.FALL);
         *  c_turnMachine.Execute(Command.FALL);
         *  c_airMachine.Execute(Command.FALL);
         *  sm_trickPhys.Execute(Command.FALL);
         *  sm_tricking.Execute(Command.READY_TRICK);
         * }
         * else
         * {
         *  debugAccessor.DisplayString("NOT DETECTIN'");
         *  debugAccessor.DisplayVector3("AIR CHECK GROUNDED", Vector3.zero);
         *  c_playerData.v_currentPosition += c_collisionData.v_attachPoint;
         *
         *  c_accelMachine.Execute(Command.LAND);
         *  c_turnMachine.Execute(Command.LAND);
         *  c_airMachine.Execute(Command.LAND);
         *  sm_tricking.Execute(Command.LAND);s
         *  sm_trickPhys.Execute(Command.LAND);
         *
         * }
         */
        if (c_collisionController.CheckGroundRotation())
        {
            // force player rotation before checking

            // is this wrong?
            Vector3 projectedRotation = Vector3.ProjectOnPlane(c_positionData.q_currentModelRotation * Vector3.forward, c_collisionData.v_surfaceNormal);
            c_positionData.q_currentModelRotation = Quaternion.LookRotation(projectedRotation, c_collisionData.v_surfaceNormal);
            c_playerData.q_currentRotation        = Quaternion.LookRotation(Vector3.ProjectOnPlane(c_playerData.q_currentRotation * Vector3.forward, c_collisionData.v_surfaceNormal));
        }
    }