Search Unity

Fixing FreeLook Camera to the back of a tank turret

Discussion in 'Cinemachine' started by ReflexiveFox, Jul 23, 2020.

  1. ReflexiveFox

    ReflexiveFox

    Joined:
    Nov 21, 2019
    Posts:
    7
    Hello people,
    i am writing here because i did not found any solution to my problem.
    Basically i want my FreeLook camera rotates togheter with the tank turret along the X axis.
    Here is a video about this problem: https://imgur.com/a/nSv5G5B (Don't care about console errors, i already fixed them).
    The closest solution that i found is in this thread (https://forum.unity.com/threads/how...rotation-and-set-camera-behind-player.598714/ , posted by Gregoryl) but i don't see the option to recenter X axis instead of the Y.
    Any help?
     
    Last edited: Jul 23, 2020
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi
    Have a look at our examples scenes: aimingRig. It uses the ThirdPersonFollow component for body, which is specifically for these kind of situations.
    You will need to control the turret with your mouse input, and set vcam with ThirdPersonFollow to follow the turret.

    Other example scenes that are related and potentially useful: 3rdPersonWithAimMode, DualTarget.

    You may need to update your Cinemachine package to see these example scenes. ;)
     
  3. ReflexiveFox

    ReflexiveFox

    Joined:
    Nov 21, 2019
    Posts:
    7
    Maybe is it better with a standard virtual camera (that i managed to lock to the turret: https://imgur.com/a/vTN7P9e) and a script component that could replace the FreeLook camera main feature (rigs)?

    Because at the moment i am focusing on developing keyboard controls, then when i move the turret with the keys the camera has to follow the turret without any damping.
    But later i want to develop standard Mouse controls (move the camera to aim and turret will follow with a delay caused by max rotation speed of turret ).

    I want to attach in both modes the FreeLook camera rigs feature to move the camera up (to see better behind near walls etc.) and down (to aim better at long distances).
     
    Last edited: Jul 26, 2020
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I agree, it's best in this case to simply parent a static vcam to the turret, and have a custom script to adjust its offset. FreeLook is overkill.