Help develop Alphys' newest puzzle!
C 529 bytes

#define M m[y][x]
char**m,*l,i;main(Y,X){for(;scanf("%ms",&amp;l)&gt;0;)(m=realloc(m,Y*8))[Y-1]=l,X=puts(m[Y++-1])-2;puts("");int s(x,y,c,d){(x&lt;0|y&lt;0|y/Y)?:({if(M^'R'&amp;&amp;M^'Y')if(M^'B'||c^2&amp;&amp;!((y&amp;&amp;m[y-1][x]=='Y')|(x&amp;&amp;m[y][x-1]=='Y')|(y&lt;Y-1&amp;&amp;m[y+1][x]=='Y')|(x&lt;X-1&amp;&amp;m[y][x+1]=='Y'))){x^X?:({M='#';return 1;});c=M^'O'?c:2;M^'U'?:({return s(x+(d&lt;4?d-2:0),y+(d&gt;3?d-5:0),1,d)?({M='#';1;}):0;});if(d^1&amp;&amp;s(x+1,y,c,3)||d^4&amp;&amp;s(x,y+1,c,6)||d^6&amp;&amp;s(x,y-1,c,4)||d^3&amp;&amp;s(x-1,y,c,1)){M='#';return 1;}}});return 0;}s(0,--Y/2,0,3);for(;i&lt;Y;)puts(m[i++]);}


We approach the puzzle by stepping first to the right, provided we are not blocked, then trying up, then down and finally back to the left.  The search is recursive and once we identify a successful path, we mark the spaces in our matrix and return.

Try it Online

Ungolfed

#include &lt;stdio.h&gt;
#include &lt;malloc.h&gt;
char**m,*l,i;
main(Y,X) {
  for(Y=1;scanf("%ms",&amp;l)&gt;0;Y++)
      m=realloc(m,Y*8),
      m[Y-1]=l,
      X=puts(m[Y-1])-2;
  puts("");
  int step(x,y,c,d,i){
    if(x&lt;0||y&lt;0||y&gt;=Y)return 0;
      if(m[y][x]=='R'||m[y][x]=='Y')return 0;
      if(m[y][x]=='B'&amp;&amp;(c==2||(y&amp;&amp;m[y-1][x]=='Y')||(x&amp;&amp;m[y][x-1]=='Y')
               ||(y&lt;Y-1&amp;&amp;m[y+1][x]=='Y')||(x&lt;X-1&amp;&amp;m[y][x+1]=='Y')))return 0;
      if(x==X){m[y][x]='#';return 1;}
      if(m[y][x]=='O')c=2;
      if(m[y][x]=='U')return step(x+(d&lt;4?d-2:0),y+(d&gt;3?d-5:0),1,d,i+1)?({m[y][x]='#';1;}):0;
      else if((d!=1&amp;&amp;step(x+1,y,c,3,i+1)) ||
    (d!=4&amp;&amp;step(x,y+1,c,6,i+1)) || (d!=6&amp;&amp;step(x,y-1,c,4,i+1)) ||
    (d!=3&amp;&amp;step(x-1,y,c,1,i+1))) {m[y][x]='#';return 1;}
      return 0;
  }
  step(0,--Y/2,0,3,0);
  for(;i&lt;Y;)puts(m[i++]);
}




Example Output 1

PYYOPPPP
YRGGRYRG
PGPBYPUR
PYRBOYOG
OBPGYYPP
PRGPOYPO
YPYOUGPP
YGROBRYY
RGRYBBOG

PYY#####
YR##RYRG
###BYPUR
#YRBOYOG
#BPGYYPP
PRGPOYPO
YPYOUGPP
YGROBRYY
RGRYBBOG


Example Output 2

PBYRYPGP
OBRGOOBG
PGPGUROO
PUGORBUG
PUPUUURO
BGGUYPRG
GBOPGGRG
PUPUBUYB
GYOPRPOG

PBYRYPGP
OBRGOOBG
PGPGUROO
PUGORBUG
###UUURO
BG#UYPRG
GB####RG
PUPUB#YB
GYOPR###


Example Output 3

RRRR
RPPR
PUOR
RPBP

RRRR
R##R
###R
R###