- Home /
Unhandled Exception Error Script
Hello, I am following FPS tutorials for unity, and when I wrote the script for first person controller, it worked, but out of the blue, with nothing changed I get this error that comes and goes saying
"Unhandled Exception: System.UnauthorizedAccessException: Access to the path "C:\Users\UserName\Desktop\FolderName\ProjectName\Temp\Assembly-CSharp-Editor.dll.mdb" is denied."
I changed the name of the user and folder for privacy, but that's the error I get. The script runs completely fine on visual studio, and the script is dragged on the object I am working with.
The main thing that's strange is sometimes I get this error and sometimes I don't. With nothing changed in the script. This has happened with other unity scripts that have already been built by Unity as well.
This is the script i am using though based off the tutorial.
" using UnityEngine; using System.Collections;
public class FirstPersonController : MonoBehaviour {
// Use this for initialization
public float movementSpeed = 5.0f;
public float mouseSensitivity = 5.0f;
public float jumpSpeed = 5.0f;
float verticalRotation = 0;
public float upDownRange = 60.0f;
float verticalVelocity = 0;
void Start()
{
Cursor.visible = false;
}
// Update is called once per frame
void Update()
{
CharacterController characterController = GetComponent<CharacterController>();
float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
transform.Rotate(0, rotLeftRight, 0);
verticalRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
verticalRotation = Mathf.Clamp(verticalRotation, -upDownRange, upDownRange);
Camera.main.transform.rotation = Quaternion.Euler(verticalRotation, 0, 0);
//movement
float forwardSpeed = Input.GetAxis("Vertical") * movementSpeed;
float sideSpeed = Input.GetAxis("Horizontal") * movementSpeed;
verticalVelocity += Physics.gravity.y * Time.deltaTime;
if (characterController.isGrounded && Input.GetButton("Jump"))
{
verticalVelocity = jumpSpeed;
}
Vector3 speed = new Vector3(sideSpeed, verticalVelocity, forwardSpeed);
speed = transform.rotation * speed;
characterController.Move(speed * Time.deltaTime);
}
}"
Just an FYI I am using this tutorial https://www.youtube.com/watch?v=WZLhtsMlrV0, but like I said this seems to be an issue with any tutorial I have used