Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Help Wanted Can you shake the video player?

Discussion in 'Scripting' started by wztk, Oct 15, 2021.

  1. wztk

    wztk

    Joined:
    Feb 25, 2020
    Posts:
    22
    Hi guys,

    I'm making a game where I use animated backgrounds in the back. To make things efficient, I use a video player with setting camera far plane. However, when I shake the camera, the video stays still. In fact, it doesnt move regardless of what the values of the gameobject's transform is.

    Is there any way you can shake the video player itself along with the camera ?
    Thanks in advance.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    6,361
    If you watch in editor when the video plays, does it create a plane object which the video is rendered on? My guess is you need to shake that plane. I haven't used far plane before, but my guess is it creates something.

    If you can't figure it out how to connect, then you can just make your own background plane and have that be the target, which should allow you to set up a reference to where the video renders.
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,582
    The camera back back is always in the same place relative to the camera, by definition. No matter where you move the camera, the back plane moves with it, period. So you'll have to change renderMode to another technique. I'd say you probably want RenderTexture and then apply that to a plane, which you in your own code will now have to place at the camera's backplane, and that code you can modify to add whatever shaking/etc you want.
     
    Brathnann likes this.
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    7,285
  5. wztk

    wztk

    Joined:
    Feb 25, 2020
    Posts:
    22
    It unfortunately doesn't create anything, but a good suggestion nonetheless. I knew I needed to move it somehow, but couldn't connect the dots.
    I've tried it and it works even without doing anything to my camera shake script. It does make it look a bit weird also, I guess I need to work out how to make it look exactly the same as I did in the other settings. Thanks!
    Good suggestion, although I haven't really played around that much with shaders, just edited couple of those I downloaded from the internet, but it would certainly be a great solution. Thanks!
     
unityunity