fork download
  1. using UnityEngine;
  2.  
  3. public class CameraController : MonoBehaviour
  4. {
  5. public float moveSpeed = 5f; // Adjust this value to control the camera movement speed
  6.  
  7. private bool isMoving;
  8. private Transform cameraTransform;
  9.  
  10. private void Start()
  11. {
  12. cameraTransform = GetComponentInChildren<Camera>().transform;
  13. }
  14.  
  15. private void Update()
  16. {
  17. if (Input.GetMouseButtonDown(0))
  18. {
  19. isMoving = true;
  20. }
  21. else if (Input.GetMouseButtonUp(0))
  22. {
  23. isMoving = false;
  24. }
  25.  
  26. if (isMoving)
  27. {
  28. MoveCamera();
  29. }
  30. }
  31.  
  32. private void MoveCamera()
  33. {
  34. Vector3 forwardDirection = cameraTransform.forward;
  35. forwardDirection.y = 0f; // Remove the vertical component
  36.  
  37. transform.position += forwardDirection * moveSpeed * Time.deltaTime;
  38. }
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.100

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Package source with Name: nuget.org disabled successfully.
Package source with Name: local added successfully.
/home/5XSTb3/Project/Program.cs(1,7): error CS0246: The type or namespace name 'UnityEngine' could not be found (are you missing a using directive or an assembly reference?) [/home/5XSTb3/Project/Project.csproj]
/home/5XSTb3/Project/Program.cs(3,33): error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?) [/home/5XSTb3/Project/Project.csproj]
/home/5XSTb3/Project/Program.cs(8,13): error CS0246: The type or namespace name 'Transform' could not be found (are you missing a using directive or an assembly reference?) [/home/5XSTb3/Project/Project.csproj]



/home/5XSTb3/Project/Program.cs(1,7): error CS0246: The type or namespace name 'UnityEngine' could not be found (are you missing a using directive or an assembly reference?) [/home/5XSTb3/Project/Project.csproj]
/home/5XSTb3/Project/Program.cs(3,33): error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?) [/home/5XSTb3/Project/Project.csproj]
/home/5XSTb3/Project/Program.cs(8,13): error CS0246: The type or namespace name 'Transform' could not be found (are you missing a using directive or an assembly reference?) [/home/5XSTb3/Project/Project.csproj]
    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:04.71
stdout
Standard output is empty