Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question My character's body shakes when I use the Cinemachine virtual camera.

Discussion in 'Cinemachine' started by ivanandriesh11, Aug 15, 2023.

  1. ivanandriesh11

    ivanandriesh11

    Joined:
    Mar 13, 2022
    Posts:
    8
    I have a first person game, and when I rotate the character on his axis his body parts shake, but on the scene itself it doesn't happen, only through cinemachine. I tried to change all combinations in CinemachineBrain in Update method and blend update method, but nothing helps. Here is a video with the usual settings. https://drive.google.com/file/d/1r9_SDiePfX5aWzSKZrGxWuMZP_d30mh1/view?usp=sharing

    The character rotation was done with a single line of code transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, mainCamera.rotation.eulerAngles.y, transform.rotation.eulerAngles.z);
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,207
    The paradigm in Cinemachine is to have separate main camera, virtual camera, and camera target. They should be 3 separate gameobjects, not parented to each other. What happens when you separate you r hierarchy along those lines?
     
  3. ivanandriesh11

    ivanandriesh11

    Joined:
    Mar 13, 2022
    Posts:
    8
    What do you mean by camera target, what do I need it for? The main camera and virtual camera are different objects with no common parent. I don't understand what third component you are talking about.
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,207
    Sorry for not being clear. You have a first person setup, with the vcam being a child of the player. The main camera is also a child of the player (which is weird). When you rotate the player, what are you rotating? The Player object, or the Y Bot child?

    upload_2023-8-16_9-23-51.png

    With Cinemachine, we try to have a separation of concerns. So, you will have a player object that the human player controls. Then, you attach a camera to that object, either using a passive camera as a child of it, or by making a separate vcam object, outside that hierarchy, that tracks the object. Also outside that object would be the main camera with the CinemachineBrain. It will in turn track the vcam. All of this indirection and separation is designed to allow dynamic flexibility with the camera: point of view switching, blending, etc.

    One question I have: why are you using Cinemachine for this? Why not just attach an ordinary camera component directly to the player? What features of Cinemachine do you need?
     
  5. ivanandriesh11

    ivanandriesh11

    Joined:
    Mar 13, 2022
    Posts:
    8
    I don't even know. In this video tutorial, we made camera control through киномашина.Do you think that it will be easier through a script and a regular camera?
     
  6. ivanandriesh11

    ivanandriesh11

    Joined:
    Mar 13, 2022
    Posts:
    8
    Через скрипт вращаю именно дочерний объект Y bot. I made them children in order to make a prefab of the character with his own camera to implement multiplayer.
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,207
    Generally speaking, I try to avoid using technology I don't need. I would set it up so that the script rotates the player, and then the camera follows that. How that last part is accomplished will depend on the needs of your game. What features do you require?
     
  8. ivanandriesh11

    ivanandriesh11

    Joined:
    Mar 13, 2022
    Posts:
    8
    I just need a first person controller)
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,207
    In that case, Cinemachine is probably overkill.
     
  10. ivanandriesh11

    ivanandriesh11

    Joined:
    Mar 13, 2022
    Posts:
    8
    The entire script can be written in Update, First the line with the character turning, then the line with the camera turning behind the character? Should there be such a sequence?
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,207
    Just make the camera a child of the head, positioned at the eyes. Then, it will turn automatically with the head.
     
  12. ivanandriesh11

    ivanandriesh11

    Joined:
    Mar 13, 2022
    Posts:
    8
    In this case, the camera will rotate instead of with its head, and the character has its own animations.
     
  13. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    Please note that the use of Cyrillic characters is causing your posts to be queued for moderation. Try not to use them then your posts will go live immediately.

    Thanks.