Search Unity

  1. Going to #UniteBerlin? Bring a buddy & get 25% off the 2nd ticket! More info here.
    Dismiss Notice
  2. Famed game designer and creator of The Sims, SimCIty, and Spore is looking for a 3D artist to join their team. Join the challenge.
    Dismiss Notice
  3. Unity 2017.4 has arrived! Read about it here.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. We've opened a new World Building sub-forum to faciltate all your world building discussions! Drop in and ask any ProBuilder, ProGrids, or PolyBrush questions.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Change ScreenX value in runtime

Discussion in 'Cinemachine' started by mr-euksinus, Apr 16, 2018 at 11:45 AM.

  1. mr-euksinus

    mr-euksinus

    Joined:
    Monday
    Posts:
    4
    Hello everyone,

    What I want to do is that when I move the player left or right the value of ScreenX (Body -> Framing Transposer) should change from 0.5f to e.g. 0.15f.

    What I do:
    - added three new variables in CinemachineFramingTransposer (m_targetPos2DX, m_targetPos2DXMin, m_targetPos2DXMax) to check if the yellow point is out of the rect;
    - I check in my script the position of yellow point and change ScreenX according to point position;

    I must say that the effect I earned does not fully satisfy me. Any advice how can I do this better way?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    960
    Why don't you just make a bigger dead zone instead?
     
  3. mr-euksinus

    mr-euksinus

    Joined:
    Monday
    Posts:
    4
    My point is that I wan't to show more scene for player according which direction he's actually walking.
    But the most important question is that my idea is good or bad? Should I change ScreenX or do something else?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    960
    Did you try using Lookahead? That's what it's for.
     
  5. mr-euksinus

    mr-euksinus

    Joined:
    Monday
    Posts:
    4
    Yes, I was working around with this but it's only working good when player's running. When he's walking camera isn't so much in front of him. Maybe I'm doing something wrong..
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    960
    You'll have to better describe the behaviour you're looking for. Certainly you could animate the Screen X position as a function of character velocity. I would do that in a separate script alongside the vcam, instead of hacking the FramingTransposer. Your script can access the FramingTransposer like this:
    var transposer = vcam.GentCinemachineComponent<CinemachineFramingTransposer>()
     
    Last edited: Apr 17, 2018 at 2:37 PM
  7. mr-euksinus

    mr-euksinus

    Joined:
    Monday
    Posts:
    4
    What I'm looking for:
    Player stays and don't move. Camera's in the middle of the scene. If he moves to the left or right side od the screen and camera point is out of the DeadZoneWidth, I want to change ScreenX respectively to the direction he's going and show more screen in front of him.
    I know I can access to the FarmingTransposer but I can't get the values when the "yellow point" is out of DeadZoneWidth.
    I'll check your idea with animate the ScreenX position.