Search Unity

Question Can I make objects invisible when entering a collider?

Discussion in 'Physics' started by raionoob1, Feb 4, 2021.

  1. raionoob1

    raionoob1

    Joined:
    Feb 4, 2021
    Posts:
    3
    I want make the character get the sword through a portal, but without the sword show up in the sphere collider region (see the print below, i hope that you can understand)
     

    Attached Files:

  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    I can think of two ways of doing this.
    1. Shader - discard all pixels behind the portal plane.
    2. During transparent pass render invisible object that will hide part of the sword behind portal (cylinder or something) but enable write to depth-buffer and than render sword also during transparent pass. Effectively this will not show sword in places where depth buffer is already written.
     
  3. raionoob1

    raionoob1

    Joined:
    Feb 4, 2021
    Posts:
    3
    how exactly can i make the first option? I tried to do the second but I couldn't understand xD
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    If you don't understand second than you will not be able to do the first one anyway.
    Please do some shader tutorials first.
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,487
    Also, please note that this is the physics forum and your post is about rendering. There's dedicated graphics forums here.