Question by
devingeesr · Dec 15, 2016 at 09:48 PM ·
c#camera
code error CS0119 field of view script
I am trying to add a field of view control on the camera so that I can zoom in on an object. I'm currently getting this error: Assets/Camera Script/ThirdPersonCamera.cs(42,27): error CS0119: Expression denotes a value', where a
method group' was expected
I'm not a coder and would like some help on how to fix this issue.
using UnityEngine;
using System.Collections;
public class ThirdPersonCamera : MonoBehaviour
{
private const float Y_ANGLE_MIN = 0.0f;
private const float Y_ANGLE_MAX = 50.0f;
public Transform lookAt;
public Transform camTransform;
private Camera cam;
private float distance = 10.0f;
private float currentX = 0.0f;
private float currentY = 0.0f;
private float sensivityX = 4.0f;
private float sensivityY = 1.0f;
public float zoomSpeed = 5;
public float minFOV = 20;
public float maxFOV = 100;
private void Start()
{
camTransform = transform;
cam = Camera.main;
}
private void Update ()
{
currentX += Input.GetAxis("Mouse X");
currentY += Input.GetAxis("Mouse Y");
//Keeps camrea from rotation under the player
currentY = Mathf.Clamp(currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
// assign zoom value to a variable
float delta = Input.GetAxis ("Zoom") * -zoomSpeed;
if(Input.GetButton ("Zoom"))
{
// make sure the current FOV is within min/max values
if((Camera.main.fieldOfView + delta > minFOV)
(Camera.main.fieldOfView + delta < maxFOV))
{
// apply the change to the main camera
Camera.main.fieldOfView = Camera.main.fieldOfView + delta;
Debug.Log ("FOV: " + Camera.main.fieldOfView);
}
}
}
private void LateUpdate ()
{
Vector3 dir = new Vector3(0,0,-distance);
Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
camTransform.position = lookAt.position + rotation * dir;
camTransform.LookAt (lookAt.position);
}
}
Comment
I would say the following line needs an AND
if((Camera.main.fieldOfView + delta > $$anonymous$$FOV)
(Camera.main.fieldOfView + delta < maxFOV))
resulting in
if((Camera.main.fieldOfView + delta > $$anonymous$$FOV) &&
(Camera.main.fieldOfView + delta < maxFOV))
Your answer
Follow this Question
Related Questions
How I can make my camera keep a distance between two objects? 0 Answers
Set the rotation axis of the camera 0 Answers
How to do a wall jump? i am very novice 0 Answers
Rotate camera when colliding 0 Answers
Camera Rotation Around Player 1 Answer