Search Unity

Custom offset in transposer camera

Discussion in 'Cinemachine' started by DanielP_, Jul 9, 2019.

  1. DanielP_

    DanielP_

    Joined:
    Jun 4, 2019
    Posts:
    16
    Hi!

    I started to use cinemachine few months ago and it's a pretty cool tool but now I'm working in a new project and I want to make a camera like Super Mario 64 and I don't know if I can get it. I'm using the Transposer with an offset (0, 3,-3) but I want that this offset only works when the camera and player are looking forward, in case player is running against the camera, this camera can't move and will keeps the position (optionally, later, I will rotate the camera to another angle behind player. To move this transposer camera I had to disable the camera, change its position and enable again)

    Is it possible to change the offset to get the desired behaviour or is there any other camera with specific settings which could let me do this (I looked for different cameras and configurations but I didn't find anything)?

    Here you can see an example of I would like to make:
    https://drive.google.com/file/d/16Sq6eb82Es56ZxS4e61Gf5tZj3f5fF8w/view?usp=sharing

    Thank you
     
    Last edited: Jul 9, 2019
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Yes, use an OrbitalTransposer with a SimpleFollowWithWorldUp binding mode. Set the offset to (0, 0, -z), where z is the distance you want the camera to be from the target.
     
    DanielP_ likes this.
  3. DanielP_

    DanielP_

    Joined:
    Jun 4, 2019
    Posts:
    16
    This setting keeps the camera at the same distance when the player is getting away from the camera and when the player is getting closer to the camera and the expected behaviour is to stay at the same position when the player is getting closer to the camer.

    In the next video you could see the current behaviour (isn't equal to SM64's video):
    https://drive.google.com/file/d/1YrscaCsBueTKel_e6C_BudL38Np1eB06/view?usp=sharing
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    That's true. You could add a custom extension to enforce a minimum camera distance.
     
  5. DanielP_

    DanielP_

    Joined:
    Jun 4, 2019
    Posts:
    16
    Thank you, testing it seems to work but there are a second question now. After enforce the distance, the player will turn, but if I want to move the camera a little to one side while I am changing that distance (like SM64) how could I make it with this binding mode?
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I think it's just damping on the aim, but I'm not 100% sure. Can you post an image of your vcam inspector, and the code you used for the minimum distance enforcing?
     
  7. DanielP_

    DanielP_

    Joined:
    Jun 4, 2019
    Posts:
    16
    I was testing about changing the aim but it didn't work. Anyway I managed to set the value of the x axis and it work better now so, to complete the job, it seems that I have to enforce the minimum distance first, then, set the value of X Axis and change the z component of the aim and after that restablish the offset of the camera. I I'm trying to make it smoothest and cool with code.
     
  8. DanielP_

    DanielP_

    Joined:
    Jun 4, 2019
    Posts:
    16
    Ups, I didn't say anyting else on this thread but finally I was be able to make it in a more basic and easy way, just moving the value of the x axis in the virtual camera with custom curves. So thanks for your help :)