Search Unity

Is it possible not having the camera moving when target is in the deadzone ?

Discussion in 'Cinemachine' started by Kiupe, Nov 21, 2018.

  1. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hello guys,

    I'm trying to prototype something simple. I have a scene, a character and a Vcam. By default the Vcam has no target. When the character is clicked I do two things :
    • I set the character as the vcam target
    • I set the character position according to the current mouse position converted to the world coordinate
    Doing this is fine the first time I click the character. The Vcam gives me an extra-feature I wanted, when the character is reaching the edges the Vcam follows so I can move character along my whole scene.

    But the next time I click on the character it seems that the Vcam moves even if the character is already in the dead zone. So during this movement, even if I do not move the mouse, the current mouse position is still converted to world coordinate, so the computed position is always different and the character position changes.

    I'm not sure what I can do to prevent that. What I want is easy to say : I want to click on my character, the camera should not moves and the character should not move. When I start moving the mouse the character should move. If I reach the edges, because of cinemachine, the vcam should moves too.

    Does that makes sense ? How would you do that ?

    Thanks
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I'm not 100% sure I understand what the problem is. Maybe this is because you haven't described the context so I'm not sure what kind of vcams you're using and how.

    Perhaps the simplest would be to upload a project that demonstrates the issue so I can understand.
     
  3. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Ok, I will do that tomorrow at the office.

    Thanks
     
  4. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hello,

    It seems that when you set a vcam target which was previously null then the vcam automatically and instantly set the target to the ScreenX and ScreenY position ignoring completely the damping. I tested that by dragging a character and when the character is close to the screen edges I set the vcam target using the character transform -> the character is instantly moved at ScreenX and ScreenY position -> not smooth at all ;-)
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Yes, that is by design. When you change a target the camera warps to the new positrion. If you want a smooth transition then you have to use a second vcam and blend to it.