/// <summary> /// retourne la direction quand on saute... /// </summary> /// <returns></returns> private Vector3 GetDirWhenJumpAndMoving() { Vector3 finalVelocityDir = Vector3.zero; //get la direction du joystick Vector3 dirInputPlayer = playerInput.GetDirInput(); //get le dot product normal -> dir Arrow float dotDirPlayer = QuaternionExt.DotProduct(worldCollision.GetSumNormalSafe(), dirInputPlayer); //si positif, alors on n'a pas à faire de mirroir if (dotDirPlayer > margeHoriz) { //direction visé par le joueur Debug.Log("Direction de l'arrow !" + dotDirPlayer); finalVelocityDir = dirInputPlayer.normalized; } else if (dotDirPlayer < -margeHoriz) { //ici on vise dans le négatif, faire le mirroir du vector par rapport à... Debug.Log("ici mirroir de l'arrow !" + dotDirPlayer); //récupéré le vecteur de DROITE de la normal Vector3 rightVector = QuaternionExt.CrossProduct(worldCollision.GetSumNormalSafe(), Vector3.forward) * -1; //Debug.DrawRay(transform.position, rightVector.normalized, Color.blue, 1f); //faire le mirroir entre la normal et le vecteur de droite Vector3 mirror = QuaternionExt.ReflectionOverPlane(dirInputPlayer, rightVector * -1) * -1; //Debug.DrawRay(transform.position, mirror.normalized, Color.yellow, 1f); //direction inverse visé par le joueur finalVelocityDir = mirror.normalized; } else { Debug.Log("ici on est proche du 90°, faire la bisection !"); //ici l'angle normal - direction est proche de 90°, ducoup on fait le milieu des 2 axe //ici faire la moyenne des 2 vecteur normal, et direction arrow finalVelocityDir = QuaternionExt.GetMiddleOf2Vector(worldCollision.GetSumNormalSafe(), dirInputPlayer); } return(finalVelocityDir); }