I wrote a script to switch cameras from 3rd person to * 1st person. 1 camera had to hook right on the head due to the character's animation so that the textures did not pass through it. After the chain, the camera starts moving because of the character's animation, so how can you remove the camera shaking due to the animation?

* 1 - the camera from the first person.

    3 answers 3

    Three obvious options come to mind:

    1. Change the position and rotation of the camera using the wonderful interpolation function Mathf.Lerp. It will smoothly bring one vector to another, which will significantly smooth out the shaking. It also works with quaternions.

    2. Attach a camera to an object that is controlled in the same way as a character, but without animation.

    3. Attach an object to the part of the character that is stationary, and already hang a camera on it

    I am sure there is something simpler, but I am an artist, I see this (:

    • I wonder how you will find the fixed part of the object if it is fully animated. Where is the logic? (: 2-3 options complete illogical nonsense ... I will try to read for the 1st ... - PiT
    • @PiT, the "animated" part of the character (i.e., the whole) is placed in the child object, i.e. you will have some Character with all the logic and a child Animated with mesh and animations, you make the camera child for Character , so it won’t shake because of the animations - Artem Cherevan
    • In fact of the matter. Look, if you just hang the camera on a character (not on a bone) , then while running or jumping it will pass through the character, but this is not good. If you hang the camera on the bone, it works fine when running and jumping, but the shaking because of the animation is very annoying. It was all very simple. I hung the camera on the character (not on the bone) and connected the camera to the bone of the head using a script. After that, I aligned the camera to Position XYZ . - PiT

    The unity has a free Cinemachine plugin, which is designed to use the camera to track an object, change plans, and all those chips that are used in the movie. The plugin is a bit complicated to understand, but if you get it right, it will help you make very decent camera spans or make a smart camera to monitor objects. Here are some good video tutorials https://unity3d.com/en/learn/tutorials/topics/animation/using-cinemachine-getting-started

    In your case, two cameras are configured, one from the first person, the second from the third. And at the right moment, their significance changes. A special CinemachineBrain controller automatically without your participation will not only make a smooth switching between cameras on the priority that has been set, but will also allow you to configure in the editor how this transition should look.

    The plugin has built-in tolerances when the object is moving to avoid jerking when playing animations and this allows you to do a smooth tracking of the object. The camera can either follow the object according to the specified rules, or watch it being in the same place. In general, the plugin is very rich in features, such as observing groups of objects, simulating camera shake when shooting from hands, switching to a camera with a better view, moving the camera along a predetermined path, etc.

      The problem is solved very simply, that I will not even lay out the script, it is very primitive. Solution: The camera is a separate object. Using the script, I change the position of the camera to the position of the head (bone) . Well, we compare the values ​​of Position

      • 2
        This is not the answer, the answer would be the script code. And so - this is your comment. The verification criterion is simple: the next person to ask a question will be helped by your comment? No - it means this is not the answer. Hints about where to go for a decision to answer are made to leave comments in question. - AK