Search Unity

how to follow 3rd person move on a cube

Discussion in 'Cinemachine' started by shshwdr, Apr 7, 2022.

  1. shshwdr

    shshwdr

    Joined:
    Mar 7, 2014
    Posts:
    7
    I tried to make a character move on a very small cube so his rotation changes a lot all the time. I tried to add a Transposer body with composer aim but when he move around the edge of the cube, or when he rotate back, the camera rotate and look at player and make me feel sick.
    I also tried to increase the angular damping but even I set it to 20, it still rotate a lot when the player rotating in a circle, because the camera always tries to get to the position after player.
    I want an effect that like a drone, it flying around player, when player go to another face of the cube, it would move and rotate, but when player rotating on a face, the camera would look it with some small look left and right, but wont try to always move to the position after player.
    feels like the camera would try to stay at a plane above player, and look at player...
    like the in following image, the circle is the player, the camera when follow to a face would try to make his up direction the same as the face normal. when player walk in a circle on a face(like the right one), the camera would move and look at player, but not always try to stay behind of the player.
    Not sure if I make myself understood. Any help would be helpful. thanks! upload_2022-4-7_2-57-27.png
     

    Attached Files:

  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    I am not sure if this will help, but it is probably related. Check out our sample scene: SphericalSurfaceFollow. You can get our sample scene from Window -> Package Manager -> Cinemachine -> Cinemachine Example Scenes.
     
    shshwdr likes this.
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    This is quite a specific use-case, so it's unlikely that you'll get an out-of-the-box solution without doing a little work.

    As a first idea, I would approach this by making an invisible gameobject to use as the vcam's Follow target. Place this object on the same cube face that the player is on. You need a script to move it to a new cube face when the player changes his face.

    Then, assign your player to the vcam's LookAt target. This way, the vcam will track the face for its position, but then rotate to look at the player from a fixed point.

    Does that make sense?
     
    shshwdr likes this.
  4. shshwdr

    shshwdr

    Joined:
    Mar 7, 2014
    Posts:
    7
    Thanks a lot! that's almost what I want except one thing I'm not sure how to set it. When I rotate to another face, the camera would move very fast to follow the player's up direction, and since everytime its a 90 degree change, it happens quite abrupt, is there a way to slow this process down a little? I tried to change all the damping values but neither slows it down... thanks in advance!
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    You could use the invisible follow target strategy here. Make an invisible object with a custom script that tracks the player tightly but when the cube side changes it moves only gradually (use SmoothDamp for this). Use that as a Follow target.