Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  4. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice

Question Can you shake the video player?

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

  1. wztk

    wztk

    Joined:
    Feb 25, 2020
    Posts:
    30
    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,745
    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,680
    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,821
  5. wztk

    wztk

    Joined:
    Feb 25, 2020
    Posts:
    30
    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