using UnityEngine; namespace Quake3Movement { public class MouseLook : MonoBehaviour {…
- User
using UnityEngine;
namespace Quake3Movement { public class MouseLook : MonoBehaviour { public float mouseSensitivity = 100f; public Transform playerBody;
float xRotation = 0f; bool cursorLocked = true; void Start() { Init(); } public void Init() { Cursor.lockState = CursorLockMode.Locked; cursorLocked = true; } public void UpdateCursorLock() { if (Input.GetKeyDown(KeyCode.Escape)) { cursorLocked = !cursorLocked; Cursor.lockState = cursorLocked ? CursorLockMode.Locked : CursorLockMode.None; } } public void LookRotation() { float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime; float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime; xRotation -= mouseY; xRotation = Mathf.Clamp(xRotation, -90f, 90f); transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f); playerBody.Rotate(Vector3.up * mouseX); } void Update() { UpdateCursorLock(); LookRotation(); } }} using UnityEngine; using Quake3Movement; namespace Quake3Movement
{ /// /// This script is used to display real-time statistics to help with tweaking and debugging. /// [RequireComponent(typeof(Q3PlayerController))] public class Q3PlayerDebug : MonoBehaviour { [Tooltip("How many times per second to update stats")] [SerializeField] private float m_RefreshRate = 4;
private int m_FrameCount = 0; private float m_Time = 0; private float m_FPS = 0; private float m_TopSpeed = 0; private Q3PlayerController m_Player; private void Start() { m_Player = GetComponent<Q3PlayerController>(); } private void LateUpdate() { // Calculate frames-per-second. m_FrameCount++; m_Time += Time.deltaTime; if (m_Time > 1.0 / m_RefreshRate) { m_FPS = Mathf.Round(m_FrameCount / m_Time); m_FrameCount = 0; m_Time -= 1.0f / m_RefreshRate; } // Calculate top velocity. if (m_Player.Speed > m_TopSpeed) { m_TopSpeed = m_Player.Speed; } } private void OnGUI() { GUI.Box(new Rect(0, 0, 130, 60), "FPS: " + m_FPS + "\n" + "Speed: " + Mathf.Round(m_Player.Speed * 100) / 100 + " (ups)\n" + "Top: " + Mathf.Round(m_TopSpeed * 100) / 100 + " (ups)"); } }} using UnityEngine;
public class MouseLook : MonoBehaviour { public float mouseSensitivity = 100f; public Transform playerBody;
float xRotation = 0f; void Start() { // Lock the cursor to the center of the screen Cursor.lockState = CursorLockMode.Locked; } void Update() { // Get mouse input float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime; float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime; // Apply vertical rotation (pitch) xRotation -= mouseY; xRotation = Mathf.Clamp(xRotation, -90f, 90f); // Apply rotations transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f); // Camera up/down playerBody.Rotate(Vector3.up * mouseX); // Player left/right } - Assistant
- User
show the whole fixed scripts instead
- Assistant
- User
Assets\Quake3Movement\Scripts\Q3PlayerController.cs(5,18): error CS0101: The namespace 'Quake3Movement' already contains a definition for 'MouseLook'
Assets\Quake3Movement\Scripts\Q3PlayerDebug.cs(5,30): error CS0246: The type or namespace name 'Q3PlayerController' could not be found (are you missing a using directive or an assembly reference?)
Assets\Quake3Movement\Scripts\Q3PlayerController.cs(13,14): error CS0111: Type 'MouseLook' already defines a member called 'Start' with the same parameter types
Assets\Quake3Movement\Scripts\Q3PlayerController.cs(18,21): error CS0111: Type 'MouseLook' already defines a member called 'Init' with the same parameter types
Assets\Quake3Movement\Scripts\Q3PlayerController.cs(24,21): error CS0111: Type 'MouseLook' already defines a member called 'UpdateCursorLock' with the same parameter types
Assets\Quake3Movement\Scripts\Q3PlayerController.cs(33,21): error CS0111: Type 'MouseLook' already defines a member called 'LookRotation' with the same parameter types
Assets\Quake3Movement\Scripts\Q3PlayerController.cs(45,14): error CS0111: Type 'MouseLook' already defines a member called 'Update' with the same parameter types
Assets\Quake3Movement\Scripts\Q3PlayerDebug.cs(15,17): error CS0246: The type or namespace name 'Q3PlayerController' could not be found (are you missing a using directive or an assembly reference?)
- Assistant
- User
show the whole Q3PlayerController script
currently it looks liek this: using UnityEngine;
namespace Quake3Movement { public class MouseLook : MonoBehaviour { public float mouseSensitivity = 100f; public Transform playerBody;
float xRotation = 0f; bool cursorLocked = true; void Start() { Init(); } public void Init() { Cursor.lockState = CursorLockMode.Locked; cursorLocked = true; } public void UpdateCursorLock() { if (Input.GetKeyDown(KeyCode.Escape)) { cursorLocked = !cursorLocked; Cursor.lockState = cursorLocked ? CursorLockMode.Locked : CursorLockMode.None; } } public void LookRotation() { float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime; float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime; xRotation -= mouseY; xRotation = Mathf.Clamp(xRotation, -90f, 90f); transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f); playerBody.Rotate(Vector3.up * mouseX); } void Update() { UpdateCursorLock(); LookRotation(); } }}
Fix it and show all ready to copy and paste
- Assistant
- User
it looks like jumping like in quake 3 arena does not work, fix it and show the whole script
- Assistant
- User
does strafe jumping like in quake 3 work? i do not notice it
- Assistant
- User
- Assistant
- User
Generate Map: pak6.pk3 UnityEngine.Debug:Log (object) GenerateMapCustomEditor:OnInspectorGUI () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:17) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
NullReferenceException: Object reference not set to an instance of an object SharpBSP.BSPHeader.ReadMagic () (at Assets/uQuake/Scripts/uQuake/Types/BSPHeader.cs:80) SharpBSP.BSPHeader..ctor (System.IO.BinaryReader BSP) (at Assets/uQuake/Scripts/uQuake/Types/BSPHeader.cs:31) SharpBSP.BSPMap.ReadHeader () (at Assets/uQuake/Scripts/uQuake/Types/BSPMap.cs:82) SharpBSP.BSPMap..ctor (System.String filename, System.Boolean loadFromPK3) (at Assets/uQuake/Scripts/uQuake/Types/BSPMap.cs:61) GenerateMap.Run () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:51) GenerateMapCustomEditor.OnInspectorGUI () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:18) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass77_0.b__0 () (at <916f8759030446de8f67b63248a8a6d1>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
- Assistant
- User
show the whole fixed script
using System.Collections.Generic; using System.IO;
namespace SharpBSP { public class BSPHeader { public BSPDirectoryEntry[] Directory { get; set; }
public string Magic { get; private set; } public uint Version { get; private set; } private BinaryReader BSP; private const int LumpCount = 17; public BSPHeader(BinaryReader BSP) { this.BSP = BSP; ReadMagic(); ReadVersion(); ReadLumps(); } public string PrintInfo() { string blob = "\r\n=== BSP Header =====\r\n"; blob += ("Magic Number: " + Magic + "\r\n"); blob += ("BSP Version: " + Version + "\r\n"); blob += ("Header Directory:\r\n"); int count = 0; foreach (BSPDirectoryEntry entry in Directory) { blob += ("Lump " + count + ": " + entry.Name + " Offset: " + entry.Offset + " Length: " + entry.Length + "\r\n"); count++; } return blob; } private void ReadLumps() { Directory = new BSPDirectoryEntry[LumpCount]; for (int i = 0; i < 17; i++) { Directory[i] = new BSPDirectoryEntry(BSP.ReadInt32(), BSP.ReadInt32()); } Directory[0].Name = "Entities"; Directory[1].Name = "Textures"; Directory[2].Name = "Planes"; Directory[3].Name = "Nodes"; Directory[4].Name = "Leafs"; Directory[5].Name = "Leaf faces"; Directory[6].Name = "Leaf brushes"; Directory[7].Name = "Models"; Directory[8].Name = "Brushes"; Directory[9].Name = "Brush sides"; Directory[10].Name = "Vertexes"; Directory[11].Name = "Mesh vertexes"; Directory[12].Name = "Effects"; Directory[13].Name = "Faces"; Directory[14].Name = "Lightmaps"; Directory[15].Name = "Light volumes"; Directory[16].Name = "Vis data"; } private void ReadMagic() { BSP.BaseStream.Seek(0, SeekOrigin.Begin); Magic = new string(BSP.ReadChars(4)); } private void ReadVersion() { BSP.BaseStream.Seek(4, SeekOrigin.Begin); Version = BSP.ReadUInt32(); } } - Assistant
- User
Assets\uQuake\Scripts\uQuake\Types\BSPHeader.cs(108,18): error CS0101: The namespace 'SharpBSP' already contains a definition for 'BSPDirectoryEntry'
Assets\uQuake\Scripts\uQuake\Types\BSPHeader.cs(114,16): error CS0111: Type 'BSPDirectoryEntry' already defines a member called 'BSPDirectoryEntry' with the same parameter types
- Assistant
- User
show the whole fixed script instead
- Assistant
- User
Generate Map: pak6.pk3 UnityEngine.Debug:Log (object) GenerateMapCustomEditor:OnInspectorGUI () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:17) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
ArgumentNullException: BinaryReader or underlying stream cannot be null Parameter name: BSP SharpBSP.BSPHeader..ctor (System.IO.BinaryReader BSP) (at Assets/uQuake/Scripts/uQuake/Types/BSPHeader.cs:29) SharpBSP.BSPMap.ReadHeader () (at Assets/uQuake/Scripts/uQuake/Types/BSPMap.cs:82) SharpBSP.BSPMap..ctor (System.String filename, System.Boolean loadFromPK3) (at Assets/uQuake/Scripts/uQuake/Types/BSPMap.cs:61) GenerateMap.Run () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:51) GenerateMapCustomEditor.OnInspectorGUI () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:18) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass77_0.b__0 () (at <916f8759030446de8f67b63248a8a6d1>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
- Assistant
- User
show all of the fixed code
- Assistant
- User
Generate Map: ztn3dm1.pk3 UnityEngine.Debug:Log (object) GenerateMapCustomEditor:OnInspectorGUI () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:17) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Could not find map 'maps/ztn3dm1.pk3' in any .pk3 file inside F:/Unity-Projects/Custom_Exo/CustomExo/Assets\baseq3 UnityEngine.Debug:LogError (object) SharpBSP.BSPMap:.ctor (string,bool) (at Assets/uQuake/Scripts/uQuake/Types/BSPMap.cs:69) GenerateMap:Run () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:51) GenerateMapCustomEditor:OnInspectorGUI () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:18) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
NullReferenceException: Object reference not set to an instance of an object GenerateMap.Run () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:56) GenerateMapCustomEditor.OnInspectorGUI () (at Assets/uQuake/Scripts/uQuake/GenerateMap.cs:18) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass77_0.b__0 () (at <916f8759030446de8f67b63248a8a6d1>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
- Assistant
The key error message here is:
Could not find map 'maps/ztn3dm1.pk3' in any .pk3 file inside F:/Unity-Projects/Custom_Exo/CustomExo/Assets\baseq3
Issue: You're passing the
.pk3filename as the map filename