Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity cinemachine lock camera axis

using UnityEngine;
using Cinemachine;
 
/// <summary>
/// An add-on module for Cinemachine Virtual Camera that locks the camera's Z co-ordinate
/// </summary>
[ExecuteInEditMode] [SaveDuringPlay] [AddComponentMenu("")] // Hide in menu
public class LockCameraZ : CinemachineExtension
{
    [Tooltip("Lock the camera's Z position to this value")]
    public float m_ZPosition = 10;
 
    protected override void PostPipelineStageCallback(
        CinemachineVirtualCameraBase vcam,
        CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
    {
        if (stage == CinemachineCore.Stage.Body)
        {
            var pos = state.RawPosition;
            pos.z = m_ZPosition;
            state.RawPosition = pos;
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: which gas is at anode 
Csharp :: list of gender binary terrorists 
Csharp :: xamarin timer example 
Csharp :: unity how to get fps c# 
Csharp :: camera follow player 
Csharp :: how to make a partical system to destroy itself after it finishing 
Csharp :: orderbyascending c# 
Csharp :: c# md5 hash file 
Csharp :: c# file exist 
Csharp :: avoid autocomplete input text asp.net 
Csharp :: how to know what object player touches unity 2D 
Csharp :: detect keypress c# 
Csharp :: vb.net open file with default program 
Csharp :: solution to fizzbuzz c# 
Csharp :: c# transparent label 
Csharp :: learn c# 
Csharp :: C# int.parse input string wasnt in correct format 
Csharp :: exit programm c# 
Csharp :: how to have is trigger on but also have collisions 
Csharp :: how to make an object jump in unity 
Csharp :: drag png to unity 3d 
Csharp :: asp net bootstrap 5 navigation bar 
Csharp :: boostrap 4 modal 
Csharp :: remove carriage returns from string c# 
Csharp :: c# writeline list 
Csharp :: C# .net core convert to int round up 
Csharp :: dotnet ef migrations to folder 
Csharp :: c# difference between two dates in milliseconds C# 
Csharp :: C# .net core convert string to enum 
Csharp :: unity on inspector change 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =