Hey, i am new to programming so my question might be really stupid and the answer really simple, but i can’t get it to work, anyway, here is my script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerFighterMovement : MonoBehaviour
{
[SerializeField]float movementSpeed = 60f;
[SerializeField]float turnSpeed = 100f;
[SerializeField]float pitchSpeed = 50f;
[SerializeField]float rollSpeed = 100f;
public float startFOV = 60f;
public float maxFOV = 90f;
public Camera myCamera;
Transform myT;
void Awake()
{
myT = transform;
}
void Update()
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
Turn();
Thrust();
if (Input.GetKeyDown("up"))
{
myCamera.fieldOfView = maxFOV;
}
else myCamera.fieldOfView = startFOV;
}
void Turn()
{
float yaw = turnSpeed * Time.deltaTime * Input.GetAxis("Mouse X");
float pitch = pitchSpeed * Time.deltaTime * Input.GetAxis("Mouse Y");
float roll = rollSpeed * Time.deltaTime * Input.GetAxis("Roll");
myT.Rotate(-pitch, yaw, roll);
}
void Thrust()
{
if (Input.GetAxis("Vertical") > 0)
myT.position += myT.forward* movementSpeed * Time.deltaTime* Input.GetAxis("Vertical");
}
}
I am doing a space game and i want to create an “speed effect” by changing the FOV. (Sorry for my english)