How to change aim from script?

How do I assign new values or access existing values of the freelook camera rigs from script? I’ve included an image with the variables I’d like to change.

Edit: I’ve managed to add an offset by using CinemachineCameraOffset. Although I’ve created the behavior that I needed I’d still appreciate an answer on how to access those variables.

vcam.GetCinemachineComonent().m_ScreenX = bla

2 Likes

Thanks

What am I doing wrong? when I press the button it crashes and shows this:

NullReferenceException: Object reference not set to an instance of an object
cameraController.Update () (at Assets/cameraController.cs:20)

This is the script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;

public class cameraController : MonoBehaviour
{
    public CinemachineVirtualCamera vcam;
    // Start is called before the first frame update
    void Start()
    {
      
    }

    // Update is called once per frame
    void Update()
    {
        if(Input.GetButton("Move"))
            {
            vcam.GetCinemachineComponent<CinemachineComposer>().m_ScreenX = 100f;
            }
        }
}

The script is in the CM FreeLook1 object.

Thank you for the help

Your vcam member is never initialized. It is null. Initialize it in Start().

1 Like