From 702b76698151a5f8953e094b322e91ba08973701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0vec?= Date: Thu, 26 Jun 2025 21:27:54 +0200 Subject: [PATCH] wip --- Assets/ParrelSync/projectCloner.asmdef | 1 + .../Prefabs/GlobalBoostrap/GameManager.prefab | 2 +- .../GlobalBoostrap/NetworkManager.prefab | 2 +- Assets/Scripts/Components/PlayerComponent.cs | 9 ++++- Assets/Scripts/Managers/GameManager.cs | 24 ++++++------- Assets/Scripts/UI/HandMenuUI.cs | 2 +- Assets/Scripts/Utils/LockToGrid.cs | 34 +++++++++---------- ProjectSettings/ProjectSettings.asset | 2 -- 8 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Assets/ParrelSync/projectCloner.asmdef b/Assets/ParrelSync/projectCloner.asmdef index 1e56b06f..d5609948 100644 --- a/Assets/ParrelSync/projectCloner.asmdef +++ b/Assets/ParrelSync/projectCloner.asmdef @@ -1,5 +1,6 @@ { "name": "ParrelSync", + "rootNamespace": "", "references": [], "includePlatforms": [ "Editor" diff --git a/Assets/Prefabs/GlobalBoostrap/GameManager.prefab b/Assets/Prefabs/GlobalBoostrap/GameManager.prefab index 04c597dd..77b59862 100644 --- a/Assets/Prefabs/GlobalBoostrap/GameManager.prefab +++ b/Assets/Prefabs/GlobalBoostrap/GameManager.prefab @@ -47,7 +47,7 @@ MonoBehaviour: rigPrefab: {fileID: 75161255762383020, guid: 1ef3259331ddc1f4d94b628323ec45f3, type: 3} player: {fileID: 0} networkManager: {fileID: 0} - autoConnectOrHost: 0 + autoConnectOrHost: 1 OnConnected: m_PersistentCalls: m_Calls: [] diff --git a/Assets/Prefabs/GlobalBoostrap/NetworkManager.prefab b/Assets/Prefabs/GlobalBoostrap/NetworkManager.prefab index e91c91fa..de7442da 100644 --- a/Assets/Prefabs/GlobalBoostrap/NetworkManager.prefab +++ b/Assets/Prefabs/GlobalBoostrap/NetworkManager.prefab @@ -72,7 +72,7 @@ MonoBehaviour: EnableNetworkLogs: 1 OldPrefabList: [] RunInBackground: 1 - LogLevel: 1 + LogLevel: 0 --- !u!114 &1446823875350840172 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Components/PlayerComponent.cs b/Assets/Scripts/Components/PlayerComponent.cs index a7918a51..66017453 100644 --- a/Assets/Scripts/Components/PlayerComponent.cs +++ b/Assets/Scripts/Components/PlayerComponent.cs @@ -11,6 +11,7 @@ using Unity.Netcode.Components; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Rendering.Universal; +using UnityEngine.UIElements; using Zenject; public class PlayerComponent : NetworkBehaviour @@ -51,7 +52,6 @@ public class PlayerComponent : NetworkBehaviour private bool isSoloRig => !networkObject.IsPlayerObject; private bool isLocalRig => networkObject.IsLocalPlayer; - private bool isRemoteRig => !networkObject.IsOwner && networkObject.IsPlayerObject; // Teleport information after player is loaded into scene @@ -162,6 +162,13 @@ public class PlayerComponent : NetworkBehaviour public void Teleport(Vector3 position, Vector3 direction) { + StartCoroutine(TeleportAtTheEndOfFrame(position, direction)); + } + + private IEnumerator TeleportAtTheEndOfFrame(Vector3 position, Vector3 direction) + { + yield return new WaitForEndOfFrame(); + if (isLoaded) { teleporter.Teleport(position, direction); diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 405d21c8..859428d5 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -3,7 +3,7 @@ using System.Collections; using Unity.Netcode; using UnityEngine; using Zenject; -using ParrelSync; +//using ParrelSync; using UnityEngine.Events; using System.Collections.Generic; @@ -45,14 +45,14 @@ public class GameManager : NetworkBehaviour if (autoConnectOrHost) { - if (ClonesManager.IsClone()) - { - JoinGame(""); - } - else - { - HostGame(); - } + //if (ClonesManager.IsClone()) + //{ + // JoinGame(""); + //} + //else + //{ + // HostGame(); + //} } } @@ -87,13 +87,13 @@ public class GameManager : NetworkBehaviour private void OnClientStarted() { OnConnected?.Invoke(); - OnClientsChanged.Invoke(networkManager.ConnectedClientsList); + //OnClientsChanged.Invoke(networkManager.ConnectedClientsList); } private void OnClientStopped(bool wasHost) { OnDisconnected?.Invoke(); - OnClientsChanged.Invoke(networkManager.ConnectedClientsList); + //OnClientsChanged.Invoke(networkManager.ConnectedClientsList); } private void OnClientConnectedCallback(ulong clientId) @@ -124,10 +124,8 @@ public class GameManager : NetworkBehaviour else { Destroy(player.gameObject); - yield return new WaitForEndOfFrame(); var playerObject = networkManager.LocalClient.PlayerObject; player = playerObject.GetComponent(); - } player.Teleport(position, rotation); diff --git a/Assets/Scripts/UI/HandMenuUI.cs b/Assets/Scripts/UI/HandMenuUI.cs index 3711f68f..3f392f9b 100644 --- a/Assets/Scripts/UI/HandMenuUI.cs +++ b/Assets/Scripts/UI/HandMenuUI.cs @@ -66,7 +66,7 @@ public class HandMenuUI : NetworkBehaviour private GameObject settings; private float forwardOffset = 0.7f; - private float upOffset = -0.3f; + private float upOffset = -0.1f; private void Start() { diff --git a/Assets/Scripts/Utils/LockToGrid.cs b/Assets/Scripts/Utils/LockToGrid.cs index 2b762ec9..b22ffede 100644 --- a/Assets/Scripts/Utils/LockToGrid.cs +++ b/Assets/Scripts/Utils/LockToGrid.cs @@ -2,23 +2,23 @@ using UnityEditor; using UnityEngine; -[ExecuteInEditMode] -public class LockToGrid : MonoBehaviour -{ - public int tileSize = 1; - public Vector3 tileOffset = Vector3.zero; +//[ExecuteInEditMode] +//public class LockToGrid : MonoBehaviour +//{ +// public int tileSize = 1; +// public Vector3 tileOffset = Vector3.zero; - void Update() - { - if(!EditorApplication.isPlaying) - { - Vector3 currentPosition = transform.position; +// void Update() +// { +// if(!EditorApplication.isPlaying) +// { +// Vector3 currentPosition = transform.position; - float snappedX = Mathf.Round(currentPosition.x / tileSize) * tileSize + tileOffset.x; - float snappedZ = Mathf.Round(currentPosition.z / tileSize) * tileSize + tileOffset.z; +// float snappedX = Mathf.Round(currentPosition.x / tileSize) * tileSize + tileOffset.x; +// float snappedZ = Mathf.Round(currentPosition.z / tileSize) * tileSize + tileOffset.z; - var snappedPosition = new Vector3(snappedX, currentPosition.y, snappedZ); - transform.position = snappedPosition; - } - } -} \ No newline at end of file +// var snappedPosition = new Vector3(snappedX, currentPosition.y, snappedZ); +// transform.position = snappedPosition; +// } +// } +//} \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 706c5ab4..aa0301c0 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -143,8 +143,6 @@ PlayerSettings: preloadedAssets: - {fileID: 0} - {fileID: 11400000, guid: 05da4dc3887e76b409ac8d96e5adcd52, type: 2} - - {fileID: -3242307658584684348, guid: 94ece74222127bf4487cc06019d68889, type: 2} - - {fileID: 11400000, guid: 5edd379c80a79174d9ef46693e5ef185, type: 2} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1