コード例 #1
0
    /// <summary>
    ///checker l'angle Vector.down & player - pivot
    ///si angle inférieur à 20, alors on est au début de la monté, autoriser (++force)
    /// </summary>
    /// <returns></returns>
    private bool IsAngleDownOk(float angleAccepted)
    {
        Vector3 dirDown  = -Vector3.up;
        Vector3 dirPivot = transform.position - pointPivot;

        float diffAngle = QuaternionExt.GetDiffAngleBetween2Vectors(dirDown, dirPivot);

        if (diffAngle <= angleAccepted)
        {
            return(true);
        }
        return(false);
    }
コード例 #2
0
    /*
     * /// <summary>
     * /// est-ce qu'on essai d'aller à l'inverse ?
     * /// </summary>
     * /// <returns></returns>
     * private bool ForceInverse()
     * {
     *  if (!isAirTense)
     *      return (true);
     *
     *  Vector3 dirPlayer = dirPlayerAirMove;
     *  Vector3 dirVelocity = rb.velocity;
     *  float velocityRigidbody = rb.velocity.sqrMagnitude;
     *
     *  if (velocityRigidbody < speedWhenCantDoInverse)
     *      return (true);
     *
     *  Vector3 dirInverse = -dirPlayer;
     *
     *  float anglePlayer = QuaternionExt.GetAngleFromVector(dirPlayer);
     *  float angleInverse = QuaternionExt.GetAngleFromVector(dirInverse);
     *  float angleVelocity = QuaternionExt.GetAngleFromVector(dirVelocity);
     *
     *  float diffAnglePlayerVelocity;
     *  QuaternionExt.IsAngleCloseToOtherByAmount(anglePlayer, angleVelocity, diffAngleInverseVelocity, out diffAnglePlayerVelocity);
     *  float diffAngleInversePlayerVelocity;
     *  QuaternionExt.IsAngleCloseToOtherByAmount(angleInverse, angleVelocity, diffAngleInverseVelocity, out diffAngleInversePlayerVelocity);
     *
     *  //si on veut aller vers la velocity, alors ok
     *  if (diffAnglePlayerVelocity < diffAngleInversePlayerVelocity)
     *  {
     *      //Debug.Log("dans le sens !");
     *      return (true);
     *  }
     *  else
     *  {
     *      //Debug.Log("inverse !");
     *      //sinon, on va trop vite pour pouvoir aller contre !
     *      return (false);
     *  }
     * }
     */


    /// <summary>
    /// ici test si on a juste inversé le pendule !
    /// </summary>
    private bool WeJustInversePendule()
    {
        //si on vient de commencer, osef, on fait normalement
        if (dirPlayerAirMove == Vector3.zero || lastDirTensity == Vector3.zero)
        {
            return(false);
        }

        float diffVector = QuaternionExt.GetDiffAngleBetween2Vectors(lastDirTensity, dirPlayerAirMove);

        if (diffVector < 90)
        {
            //on a pas inversé
            return(false);
        }
        //on a inversé !
        return(true);
    }