Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Question Deadzone margin-top and margin-bottom

Discussion in 'Cinemachine' started by zt3ff3n, Dec 6, 2020.

  1. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    37
    Hi.

    I'm trying to make a plaltformer camera that allows for a lot of Y movement before tracking. It also needs to frame the player far down in the viewport. This works current setup works if the player moves out of frame on a positive Y axis. But not in the negative Y axis, as the deadzone expands out of view in the negative Y axis.

    Can I set that "border" manually somehow?

    unknown-1.png unknown.png
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,744
    Reduce your dead zone and soft zone heights so that they are less than 1. 1 means the entire height of the screen.
     
  3. zt3ff3n

    zt3ff3n

    Joined:
    Feb 19, 2016
    Posts:
    37
    Still, that centers the player in the middle of the screen. If I adjust the *Screen Y* parameter, I get the off-set I'm after, where the player is in the lower half of the view - but, that does *not* shift the dead-zone, meaning, it looks like the attached screenshot. That lets the player fall "out of the screen" when moving down the Y axis..
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,744
    Dead zone means that the player can be anywhere inside it and the camera won't adjust. So it's not accurate to say that the player will be centered in the screen if you have a nonzero dead zone.

    You can set up the dead zone you describe but I suspect that's not the best solution, as there is nothing that will push the camera to frame the player at the bottom of the dead zone.

    upload_2020-12-7_15-2-41.png

    Maybe a better solution would be to set it up with no dead zone, only soft zones, and set the center Y parameter to be low in the screen. Implement the dead zone by creating a "shadow" player: an empty game object with a custom script that sets its position to match the player's X co-ord, and puts the Y on the ground. Use that as the follow target instead of the player. When the player's Y changes enough to go to a new level, then snap the shadow's Y to the new level, and let the vcam damp its way there thanks to the soft zone. I think something like that will give you good camera control for a platformer.