Vyn Halcyon
New member
Hi!
This is basically what I want to do:
It works, but the camera FOV is snapped back to default settings, which leads me to believe a state or viewtype preset is setting the field of view back to 60 on update().
What would be the best practise/approach to solving this?
I was wondering if I ought to create a viewtype and/or state that is conducive to scrollwheel zooming, but I woudl prefer avoiding writing something from scratch, all just to zoom. What would be a good starting point for overriding or atleast prevent whatever it is that sets the FOV back to some pre-determiend value on update?
Thank you for your time.
This is basically what I want to do:
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraScrollWheelZoom : MonoBehaviour
{
public Camera selectedCamera;
private void Awake()
{
selectedCamera = GetComponent<Camera>();
}
// Update is called once per frame
void Update()
{
if (Input.mouseScrollDelta.y > 0)
{
selectedCamera.fieldOfView--;
Debug.Log("Scrollwheel up working");
}
{
if (Input.mouseScrollDelta.y < 0)
{
selectedCamera.fieldOfView++;
Debug.Log("Scrollwheel down working");
}
}
}
}
It works, but the camera FOV is snapped back to default settings, which leads me to believe a state or viewtype preset is setting the field of view back to 60 on update().
What would be the best practise/approach to solving this?
I was wondering if I ought to create a viewtype and/or state that is conducive to scrollwheel zooming, but I woudl prefer avoiding writing something from scratch, all just to zoom. What would be a good starting point for overriding or atleast prevent whatever it is that sets the FOV back to some pre-determiend value on update?
Thank you for your time.