zoukankan      html  css  js  c++  java
  • Cinemachine v2.2.8 学习

    https://docs.unity3d.com/Packages/com.unity.cinemachine@2.2/manual/index.html

    https://blog.csdn.net/tanyu159/article/details/88608559

    https://learn.unity.com/tutorial/overview-of-cinemachine?language=en

    https://learn.unity.com/tutorial/cinemachine?language=en

    Cinemachine is a suite of modules for operating the Unity camera. Cinemachine solves the complex mathematics and logic of tracking targets, composing, blending, and cutting between shots. 

    Cinemachine overview

    Getting started

    Setting up Virtual Cameras

    Saving in Play Mode

    Setting Virtual Camera properties

    Working with noise profiles

    Setting Cinemachine Brain properties

    Blending between Virtual Cameras

    Cinemachine and Timeline

    Storyboard

    Cinemachine and Postprocessing

    Managing and grouping Virtual Cameras

    Avoiding collisions and evaluating shots

    Cinemachine Target Group

    Cinemachine and 2D graphics

    Cinemachine and top-down games

    Using multiple Unity cameras

    Cinemachine External Camera

    Cinemachine Follow Zoom

    Using dolly paths

    Cinemachine Impulse

    Cinemachine overview

    Using Cinemachine requires a new way of thinking about working with cameras.  For example, you might have already invested heavily in carefully scripted camera behaviors. However, Cinemachine can give the same results, if not better, in less time, Get up and running quickly to create and tune cameras without bothering your engineer.

      Virtual Cameras

    Cinemachine does not create new cameras. Instead, it directs a single Unity camera for multiple shots. You compose these shots with Virtual Cameras. Virtual Cameras move and rotate the Unity camera and control its settings.

    The Virtual Cameras are separate GameObjects from the Unity Camera, and behave independently. They are not nested within each other.

    The main tasks that the Virtual Camera does for you:

    • Position the Unity camera in the Scene
    • Aim the Unity camera at something
    • Add procedural noise to the Unity camera. Noise simulates things like handdeld effects or vehicle shakes

    Cinemachine encourages you to create many Virtual Cameras. The Virtual Camera is designed to consume little processing power. If your Scene is performance-senstive, deactivate all but the essential Virtual Cameras at any given moment for extreme performance.

    A good rule of thumb is to use a single Virtual Camera for a single shot. Take advantage of this to create dramatic or subtle cuts or blends. Examples:

    • For
    • Duplicate

    One Virtual Camera has control of the Unity camera at any point in time. This is the live Virtual Camera. The only exception to this rule is during a blend from one Virtual Camera to the next. During blending, both Virtual Cameras are live. 

      Cinemachine Brain

    The Cinemachine Brain is a component in the Unity Camera itself. Cinemachine Brain monitors all active Virtual Cameras in the Scene. To specify the next live Virtual Camera, you active or deactive the desired Virtual Camera's game object. Cinemachine Brain then choose the most recently activated Virtual Camera with the same or higher priority as the live Virtual Camera. It performs a cut or blend between the previous and new Virtual Cameras

    Tip: Use Cinemachine Brain to respond to dynamic game events in real time. It allows your game logic to control the camera by manipulating priorities. This is particularly useful for live gameplay, where action isn't always predictable. Use Timeline to choreograph cameras in predictable situations, like cutscenes. Timeline overrides the Cinemachine Brain priority system to give you precise, to-the-frame camera control. 

      Moving and aiming

    Use the Body properties in a Virtual Camera to specify how to move it in the Scene. Use the Aim properties to sepcify how to rotate it.

    A Virtual Camera has two targets:

    • The Follow target specifies a GameObject for the Virtual Camera to move with.
    • The Look At target specifies the GameObject to aim at

    Cinemachine includes a variety of procedural algorithms to control moving and aiming. Each algorithm solves a specific problem, and has properties to customize the algorithm for your specific needs.

    Cinemachine implements these algorithms as CinemachineComponent objects. Use the CinemachineComponent class to implement a custom moving or aiming behavior.

    The Body properties offer the following procedural algorithms for moving the Virtual Camera in a Scene:

    • Transposer:  Move in a fixed relationship to the Follow target, with optional damping.
    • Do Nothing:  Do not move the Virtual Camera.
    • Framing Transposer:  Move in a fixed screen-space relationship to the Follow target, with optional damping.
    • Orbital Transposer:  Move in a variable relationship to the Follow target, optionally accepting player input.
    • Tracked Dolly:  Move along a predefined path.
    • Hard Lock to Target:  Use the same position at the Follow target.

    The Aim properties offer the following procedural algorithms for rotating a Virtual Camera to face the Look At target:

    • Composer:  Keep the Look At target in the camera frame, with compositional constraints.
    • Group Composer:  Keep multiple Look At targets in the camera frame.
    • Do Nothing:  Do not rotate Virtual Camera.
    • POV:  Rotate the Virtual Camera based on the user's input.
    • Same As Follow Target:  Set the camera's rotation to the rotation of the Follow target.
    • Hard Look At:   Keep the Look At target in the center of the camera frame.

      Composing a shot

    The Framing Transposer, Composer, and Group Composer algorithms define areas in the camera frame for you to compose a shot:

    • Dead Zone:  The area of the frame that Cinemachine keeps the target in.
    • Soft Zone:  If the target enters this region of the frame, the camera will re-orient to put it back in the dead zone. It will do this slowly or quickly, according to the time specified in the Damping settings.
    • Screen:  The screen position of the center of the dead zone. 0.5 is the center of the screen.
    • Damping:  Simulates the lag that a real camera operator introduces while operating a heavy physical camera. Damping specifies quickly or slowly the camera reacts when the target enters the soft zone while the camera tracks the target. Use small numbers to simulate a more responsive camera, rapidly moving or aiming the camera to keep the target in the dead zone. Larger numbers simulate heavier cameras, The larger the value, the more Cinemachine allows the target to enter the soft zone.

    The Game Window Guides gives an interactive, visual indication of these areas. The guides appear as tinted areas in the GameView 

    The clear area indicates the dead zone. The  blue-tinted area indicates the soft zone.The position of the soft and dead zones indicates the screen position. The red-tinted area indicates the no pass area, which the target never enters. The yellow square indicates the target.

    Adjust these area to get a wide range of camera behaviors. To do this, drag their edges in the Game view or edit their properties in the Inspector window. For example, user larger damping values to simulate a larger, heavier camera, or enlarge the soft zone and dead zone to create an area in the middle of the camera frame that is immune to target motion. Use this feature for things like animation cycles, where you don't want the camera to track the target if it moves just a little.

      Using noise to simulate camera shake

    Real-world physical cameras are often heavy and cumbersome. They are hand-held by the camera operator or mounted on unstable objects like moving vehicles. Use Noise properties to simulate these real-world qualities for cinematic effect. For example, you could add a camera shake when following a running character to immerse the player in the action.

    At each frame update, Cinemachine adds noise separately from the movement of the camera to follow a target. Noise does not influence the camera's position in future frames. This separation ensures that properties like damping behave as expected.

    Getting started

      Installing Cinemachine

      Upgrading from the Cinemachine Asset Package

      Learning more about Cinemachine

    Setting up Virtual Cameras

    In your project, organize your Scene Hierarchy to have a single Unity camera with a CinemachineBrain component and many Virtual Cameras

    To add a Virtual Camera to a Scene:

    1. In the Unity menu, choose Cinemachine -> Create Virtual Camera. Unity adds a new GameObject with a Cinemachine Virtual Camera component. If necessary, Unity also adds a Cinemachine Brain component to the Unity camera GameObject for you.
    2. Use the Follow property to specify a GameObject to follow. The Virtual Camera automatically positions the Unity camera relative to this GameObject at all times, even as you move it in the Scene.
    3. Use the Look At property to specify the GameObject that the Virtual Camera should aim at. The Virtual Camera automatically rotates the Unity camera to face this GameObject at all times, even as you move it in the Scene.
    4. Customize the Virtual Camera as needed. Choose the algorithm for following and looking at, and adjust settings such as the follow offset, the follow damping, the screen composition, and the damping used when re-aiming the camera.

    Saving in Play Mode

    Check Save During Play on any Virtual Camera in the Inspector to enable this feature. This is a global property, not per-camera, so you only need to check or uncheck it once.

    Cinemachine components have the special attribute [SaveDuringPlay] to enable this functionality. Feel free to use it on classes within your own custom scripts too if you need it. To exclude a field in a class with the [SaveDuringPlay] attribute, add the [NoSaveDuringPlay] attribute to the field. 

    Setting Virtual Camera properties

    The Cinemachine Virtual Camera is a component that you add to an empty GameObject. It represents a Virtual Camera in the Unity Scene.

    Use the Aim, Body, and Noise properties to specify how the Virtual Camera animates position, rotation, and other properties. The Virtual Camera applies these settings to the Unity Camera when Cinemachine Brain or Timeline

      Body properties

    Use the Body properties to specify the algorithm that moves the Virtual Camera in the Scene

        Transposer

    This Virtual Camera Body algorithm moves the Virtual Camera in a fixed offset to the Follow target. It also applies damping.

        Property      Function

    • Binding Mode:   The coordinate space to use when intepreting the offset from the target, and the damping. For example, for a "Door Cam" or "Hood Cam" in a car racing game, use Local Space Locked To Target
      • Lock To Target On Assign:  Make the Virtual Camera use the Follow target's local frame at the moment that the Virtual Camera is activated or when the target is assigned. This offset remains constant in world space. Also, the camera does not rotate along with the target.
      • Lock To Target With World Up:  Make the Virtual Camera use the Follow target's local frame with tilt and roll set to 0. This binding mode ignores all target rotations expect yaw.
      • Lock To Target No Roll:  Make the Virtual Camera use the Follow target's local frame, with roll set to 0.
      • Lock To Target:  Make the Virtual Camera use the Follow target's local frame. As the target rotates, the camera rotates around it to maintain the offset.
      • World Space:  The offset in interpreted in world space relative to the Follow target's origin. The camera will not change position when the target rotates.
      • Simple Follow With World Up:  Interpret the offset and damping values in camera-local space. This mode emulates what a human camera operator would do when instructed to follow a target
    • Follow Offset:  The distance to maintain the Virtual Camera relative to the Follow target. Set X, Y, and Z to 0 to place the camera at the centre of the target. The default is 0, 0, -10, respectively, which places the camera behind the target.
    • X Damping:  How responsively the camera tries to maintain the offset in the x-axis. Small numbers make the camera more responsive. Larger number make the camera respond more slowly
    • Y Damping:  How responsively the camera tries to maintain the offset in the y-axis. Small numbers make the camera more responsive. Larger numbers make the camera respond more slowly.
    • Z Damping:  How responsively the camera tries to maintain the offset in the z-axis. Small numbers make the camera more responsive. Larger numbers make the camera respond more slowly.
    • Pitch Damping:  How responsively the camera tracks the target rotation’s x angle. Small numbers make the camera more responsive. Larger numbers make the camera respond more slowly.
    • Yaw Damping:  How responsively the camera tracks the target rotation’s y angle. Small numbers make the camera more responsive. Larger numbers make the camera respond more slowly.
    • Roll Damping:  How responsively the camera tracks the target rotation’s z angle. Small numbers make the camera more responsive. Larger numbers make the camera respond more slowly.

        Do Nothing

    This Virtual Camera Body algorithm does not move the Virtual Camera; it does not modify its position. Choose this algorithm for static or for animating the camera position directly with your custom scripts.

         Framing Transposer

    This Virtual Camera Body algorithm moves the camera in a fixed screen-space relationship to the Follow target. You can specify offset, damping, and composition rules. Framing Transposer only changes the camera's position in space. It does not re-orient or otherwise aim the camera.

    Framing Transposer is designed for 2D and orthographic cameras. But it works equally well with perspective cameras and 3D environments.

        Orbital Transposer

        Tracked Dolly

        Hard Lock to Target

      Aim properties

    Use the Aim properties to specify how to rotate the Virtual Camera.

        Composer

    This Virtual Camera Aim algorithm rotates the camera to face the Look At target. It also applies offsets, damping, and composition rules. Examples of targets for aiming: the upper spine or head bone of a character, vehicles, or dummy objects which are controlled or animated programmatically.

          Property        Function

    • Tracked Object Offset:  Offset from the center of the Look At target, in target-local space. Fine-tune the tracking target position when the desired area is not the tracked object's center.
    • Lookahead Time:  Adjust the offset based on the motion of the Look At target. The algorithm estimates the point that the target will be this many seconds into the future. This feature is senstive to noisy animation. It can amplify the noise, resulting in undesirable camera jitter. If the camera jitters unacceptable when the target is in motion, turn down this property or animate the target more smoothly.
    • Lookahead Smoothing:  Controls the smoothness of the lookahead algorithm. Larger values smooth out jittery predications and increase prediction lag.
    • Lookahead Ignore Y:  Toggle to ignore movement along the Y axis for lookahead calculations.
    • Horizontal Damping:  How responsively the camera follows the target in the screen-horizontal directions. Use small numbers for mroe responsive, rapid rotation of the camera to keep the target in the dead zone. Use larger numbers for a more heavy, slowly-responding camera.
    • Vertical Damping:  How responsively the camera follows the target in the screen-vertical direction. Use different vertical and horizontal settings to give a wide range of camera behaviors.
    • Screen X:  Horizontal screen position for the center of the dead zone. The camera rotates so that the target appears here.
    • Screen Y:  Vertical screen position for target, The camera rotates so that the target appears here.
    • Dead Zone Width:  The width of the screen region within which the camera ignores any movement of the target. If the target is positioned anywhere within this region, the Virtual Camera does not update its rotation. This is useful for ignoring minor target movement
    • Dead Zone Height:  The height of the screen region within which the camera ignores any movement of the target. If the target is positioned anywhere within this region, the Virtual Camera does not update its rotation. This is useful for ignoring minor target movement.
    • Soft Zone Width:  The width of the soft zone. If the target appears in this region of the screen, the camera will rotate to push it back out to the dead zone, in the time specified by the Horizontal Damping setting
    • Soft Zone Height:  The height of the soft zone. If the target appears in this region of the screen, the camera will rotate to push it back out to the dead zone, in the time specified by the Vertical Damping setting.
    • Bias X:  Positions the soft zone horizontally, relative to the dead zone.
    • Bias Y:  Positions the soft zone vertically, relative to the dead zone.

        Group Composer

    This Virtual Camera Aim algorithm aims the camera at multiple GameObjects. Otherwise, it behaves identically to the Composer and has the same settings. If the Look At target is a Cinemachine Target Group, the algorithm adjusts the FOV and the camera distance to ensure that the group of targets is framed properly. 

        Do Nothing

     This Virtual Camera Aim algorithm does not aim the Virtual Camera. Choose 

        POV

    This Virtual Camera Aim algorithm aims the camera in response to the user's input.

        Same As Follow Target

        Hard Look At

      Noise properties

      Extensions

    Working with noise profiles

    Setting Cinemachine Brain properties

    The Cinemachine Brain is a component in the Unity camera itself. Cinemachine Brain monitors all active Virtual Camera in the Scene. It choose the next Virtual Camera to control the Unity camera. It also controls the cut or blend from the current Virtual Camera to the next

    To add a Cinemachine Brain component to a Unity camera, do one of the following:

    • Add a Virtual Camera, or other Cinemachine object, to your Scene. Unity adds a Cinemachine Brain component to the Unity camera for you if there isn't one already.
    • Add a Cinemachine Brain component to the Unity camera yourself.

    Tip: You can also control Virtual Cameras from Timeline. Timeline overrides the decisions that Cinemachine Brain makes

    Cinemachine Brain holds the following key properties:

    • Blend Settings:  A list that defines how to blend from one Virtual Camera to another. For example, add an item to the list for a 4 second blend from vcam1 to vcam2 then add another item for a 1 second blend from vcam2 back to vcam1. If a blend between two cameras isn't defined, Cinemachine Brain uses its default blend.
    • Layer Filter:  Cinemachine Brain uses only those Virtual Cameras that pass the culling mask of the Unity camera. You can set up split-screen environments by using the culling mask to filter layers.
    • Event Dispatching:  Cinemachine Brain fires events when it changes shot. It fires an event when a Virtual Camera goes live. It also fires an event when it cuts from one Virtual Camera to another. Use the latter event to reset temporal post effects.

        Property          Function

    • Show Debug Text:  Check to display a textual summary of the live Virtual Camera and blend in the view.
    • Show Camera Frustum:  Check to display the frustum of the camera in the Scene view.
    • Ignore Time Scale:  Check to make the Virtual Cameras respond in the real time to user input and damping, even if the game is running in slow motion.
    • World Up Override:  The Y axis of the specified GameObject defines the worldspace up vector for Virtual Cameras. Use this property in top-down game environments. Set to None to use the worldspace Y axis. Setting this appropriately is important to avoid gimbal-lock in extreme up/down conditions.
    • Update Method:  When to update the position and rotation of the Virtual Cameras.
      • Fixed Update:  Synchronize Virtual Camera update with the Physics module, in FixedUpdate.
      • Late Update:  In MonoBehaviour LateUpdate
      • Smart Update:  Update each virtual camera according to how its target is updated. This is the recommended setting.
    • Default Blend:  The blend to use when you haven't explicitly defined a blend between two Virtual Cameras
      • Cut:  Zero-length blend.
      • Ease In Out:  S-shaped curve, giving a gentle and smooth transition.
      • Ease In:  Linear out of the outgoing shot, and easy into the incoming.
      • Ease Out:  Easy out of the outgoing shot, and linear into the incoming.
      • Hard In:  Easy out the outgoing, and hard into the incoming.
      • Hard Out:  Hard out of the outgoing, and easy into the incoming.
      • Linear:  Linear blend. Mechanical-looking.
      • Custom:  Custom blend curve. Draw the curve you want.
    • Custom Blends:  The asset that contains custom settings for blends between specific Virtual Cameras in your Scene.
    • Create Asset:  Create an asset containing a list of custom blends between Virtual Cameras.
    • Camera Cut Event:  This event fires when a Virtual Camera goes live and there is no blend.
    • Camera Activated Event:  This event fires when a Virtual Camera goes live. If a blend is involved, then the event fires on the first frame of the blend.

    Blending between Virtual Cameras

    Cinemachine and Timeline

    Storyboard

    Cinemachine and Postprocessing

    Managing and grouping Virtual Cameras

    Avoiding collisions and evaluating shots

    Cinemachine Target Group

    Cinemachine and 2D graphics

    Cinemachine and top-down games

    Using multiple Unity cameras

    Cinemachine External Camera

    Cinemachine Follow Zoom

    Using dolly paths

    Cinemachine Impulse

  • 相关阅读:
    static link:关于gcc连接静态库的几种方式
    gcc同时使用动态和静态链接
    解决 liblog4cpp.a: could not read symbols: Bad value
    lombok 下的@Builder注解用法
    mybatis-plus id主键生成的坑
    关于mybatis-plus 和 mybatis-plus-boot-starter 异同点分析
    解决SpringBoot2.0集成Swagger2访问404的问题
    Google 开源的这个库,性能快到让程序员飞起来!
    解决mybatisplus saveBatch 或者save 无法插入主键问题
    intellij IDEA github clone 指定分支代码
  • 原文地址:https://www.cnblogs.com/revoid/p/12898799.html
Copyright © 2011-2022 走看看