Search Unity

Creating a locked camera

Discussion in 'Cinemachine' started by walaber_entertainment, Dec 9, 2017.

  1. walaber_entertainment

    walaber_entertainment

    Joined:
    Jul 10, 2017
    Posts:
    30
    Hey all-

    I'm trying to make what is essentially a camera with a locked offset from an object- imagine a GoPro attached to a helmet on a character.

    I can use "Hard Lock To Target" for Body, and "Hard Look At" for Aim, but this appears to do a LookRotation under the hood, so if the player turns upside down the camera doesn't turn upside down with it (it always wants +Y to be up).

    How can I avoid this? I saw something in the build notes for the latest version that mentioned a new Aim component that would lock to the rotation of the target, but I can't find it anywhere.
     
  2. walaber_entertainment

    walaber_entertainment

    Joined:
    Jul 10, 2017
    Posts:
    30
    OK as usual asking the question lead to some solutions. one of course is just to make the virtual camera object a child of the object it should be attached to, and then set body and aim to both "do nothing".

    Also, it seems Body set to Transposer with binding mode = Lock To Target and then Aim set to Composer also works properly (but allows for damping, etc).
     
  3. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    If your helmet is part of a character that is getting animated, then you'd potentially have to put the camera as a child of the head-bone.

    But that comes with some problems (being a child of some gameobject), namely that you are getting deleted once the parent object gets deleted.

    A better way to do this would be to use the new "Same as target" rotation mode for "aim".
    That way you can be attached to the head/helmet with some offset (using the transposer) + always copy over the rotation of the head, essentially becoming a fake-child, with the bonus of not getting deleted along with the character object.
     
    Gregoryl likes this.
  4. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Grab the latest CM from the Asset Store if you haven't already.

    Body: Lock to Target. Set all damping to 0
    Aim: Same as Follow Object
    upload_2017-12-11_10-8-19.png
     
    Gregoryl likes this.
  5. walaber_entertainment

    walaber_entertainment

    Joined:
    Jul 10, 2017
    Posts:
    30
    Thanks for the reply, this has helped a lot!