UnauthorizedAccessException | I Need Help Here.
Hello, So I've Been Getting Into Game Development Alot, And I Got Bored & Decided To Make My Own Block Game Where You Dodge Other Blocks, I Have Alot Of Scripts But I'm No Professional So I Don't 100% Know If It Has To Do With A Script Or My PC Being Stupid.
Error: UnauthorizedAccessException: Access to the path "Temp\StagingArea\Block Runner.exe" or "C:\Users\Codex\Desktop\Block Runner.exe" is denied. System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:124)
Second Error: UnityEditor.BuildPlayerWindow+BuildMethodException: Build failed with errors. at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x001b9] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:162
I Appreciate Any Help Given!
Scripts (Alot):
LevelComplete: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class LevelComplete : MonoBehaviour { public void LoadNextLevel() { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } }
EndTrigger:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class EndTrigger : MonoBehaviour { public PlayerMovement movement; public GameManager gameManager; void OnTriggerEnter() { gameManager.CompleteLevel(); }
}
PlayerMovement: using UnityEngine;
public class PlayerMovement : MonoBehaviour { public Rigidbody rb; public float forwardForce = 2000f; //Movement Speed public float sidewaysForce = 500f;
// Update is called once per frame
void FixedUpdate ()
{
//Add a Forward Force (Movement Speed)
rb.AddForce(0, 0, forwardForce * Time.deltaTime);
if ( Input.GetKey("d"))
{
rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0);
}
if (Input.GetKey("a"))
{
rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0);
}
if (rb.position.y < -1f)
{
FindObjectOfType<GameManager>().EndGame();
}
}
}
PlayerCollision:
using UnityEngine;
public class PlayerCollision : MonoBehaviour { public PlayerMovement movement; void OnCollisionEnter (Collision collisionInfo) { if (collisionInfo.collider.tag == "Obstacle") { //What Happens When You Hit An Obstacle. movement.enabled = false; FindObjectOfType().EndGame(); } } }
GameManager:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour { bool gameHasEnded = false; public float restartDelay = 1f; public GameObject completeLevelUI; public void CompleteLevel() { completeLevelUI.SetActive(true); } public void EndGame() { if (gameHasEnded == false) { gameHasEnded = true; Debug.Log("GAME OVER"); Invoke("Restart", restartDelay); } } void Restart() { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } }
Score:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Score : MonoBehaviour { public Transform player; public Text scoreText; // Update is called once per frame void Update () { scoreText.text = player.position.z.ToString("0");
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612135401im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to Build Build Eclipse (Android) projects on Unity 2020.3.1f1 ? 1 Answer
Cannot Build with UCB, Error related to Purchasing and UI? Unity 2019.3.5 1 Answer
GameObject doesn't load ammocounter prefab from FPS microgame (Unity 2018.4.18) 0 Answers
UWP build failed to restore NuGet packages 1 Answer
Text not showing in build (but the rest of UI shows up) 1 Answer