using Unity.Cinemachine; using UnityEngine; using UnityEngine.InputSystem; public class SwitchPlayerNew : MonoBehaviour { [Header("Input Action References")] [SerializeField] private InputActionReference switcherAction; [Space] [Header("Cinemachine Settings")] [SerializeField] private CinemachineCamera _camera; [SerializeField] private CinemachineFollow followComponent; [SerializeField] private Vector3 defaultOffset = new Vector3(5f, 0.5f, 0f); [SerializeField] private Vector3 switchPlayerOffset = new Vector3(10f, 4f, 1f); private bool usingswitchPlayerOffset = false; void Start() { followComponent = _camera.GetComponent<CinemachineFollow>(); } void Update() { SwitchPlayers(); } private void SwitchPlayers() { if (switcherAction.action.WasPerformedThisFrame()) { usingswitchPlayerOffset = !usingswitchPlayerOffset; if(followComponent != null) { followComponent.FollowOffset = usingswitchPlayerOffset ? switchPlayerOffset : defaultOffset; } } } void OnEnable() { switcherAction.action.Enable(); } }