Compare commits

...

2 Commits

Author SHA1 Message Date
f940378cb6 fixing merge issue 2025-11-11 17:07:32 +02:00
c71e260afc modified elevator to try make it work in multiplayer. Still has sync problems. 2025-11-11 17:03:45 +02:00
10 changed files with 1428 additions and 1432 deletions

4
.gitignore vendored
View File

@@ -99,7 +99,7 @@ Recordings/
# If the source bank files are kept outside of the StreamingAssets folder then these can be ignored. # If the source bank files are kept outside of the StreamingAssets folder then these can be ignored.
# Log files can be ignored. # Log files can be ignored.
fmod_editor.log fmod_editor.log
NetrworkManagerUI.prefab Assets/_PROJECT/Components/Overlay UI/NetworkManagerUI.prefab
NetrworkManagerUI.prefab.meta Assets/_PROJECT/Components/Overlay UI/NetrworkManagerUI.prefab.meta
CustomNetworkManager.prefab CustomNetworkManager.prefab
CustomNetworkManager.prefab.meta CustomNetworkManager.prefab.meta

View File

@@ -27,7 +27,7 @@ PluginImporter:
- first: - first:
Standalone: Win64 Standalone: Win64
second: second:
enabled: 1 enabled: 0
settings: {} settings: {}
userData: userData:
assetBundleName: assetBundleName:

View File

@@ -1,3 +1,4 @@
using FishNet.Object;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@@ -9,7 +10,7 @@ public enum ElevatorMoveState
Decending Decending
} }
public class ElevatorStatusPlate : MonoBehaviour public class ElevatorStatusPlate : NetworkBehaviour
{ {
[System.Serializable] [System.Serializable]
public struct FloorNumbers public struct FloorNumbers

View File

@@ -1,4 +1,5 @@
using _PROJECT.NewHandPresence; using _PROJECT.NewHandPresence;
using FishNet.Object;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Unity.XR.CoreUtils; using Unity.XR.CoreUtils;
@@ -14,7 +15,7 @@ public enum ElevatorState
} }
public class ElevatorBox : MonoBehaviour public class ElevatorBox : NetworkBehaviour
{ {
public List<ElevatorOuter> callers = new List<ElevatorOuter>(); public List<ElevatorOuter> callers = new List<ElevatorOuter>();
@@ -129,8 +130,10 @@ public class ElevatorBox : MonoBehaviour
} }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
{ {
XROrigin enteredPlayerVR = other.GetComponent<XROrigin>(); XROrigin enteredPlayerVR = other.GetComponent<XROrigin>();
KbmController enteredPlayerKbm = other.GetComponent<KbmController>(); KbmController enteredPlayerKbm = other.GetComponent<KbmController>();
XRPlayerMirror networkPlayerDisplay = other.GetComponentInParent<XRPlayerMirror>();
Debug.Log("Player Entered box"); Debug.Log("Player Entered box");
if (enteredPlayerVR != null) if (enteredPlayerVR != null)
@@ -141,11 +144,19 @@ public class ElevatorBox : MonoBehaviour
{ {
enteredPlayerKbm.transform.SetParent(this.transform); enteredPlayerKbm.transform.SetParent(this.transform);
} }
else else if (networkPlayerDisplay != null)
{
//don't do any parenting but don't halt the function
}
else {
Debug.Log(other + " Cannot ride in lifts.");
return; return;
}
Debug.Log("Calling Lift transfer sequence");
switch (targetFloor) switch (targetFloor)
{ {
case int f when f == floors[0].floorNumber: case int f when f == floors[0].floorNumber:
targetFloor = floors[1].floorNumber; targetFloor = floors[1].floorNumber;
@@ -158,7 +169,7 @@ public class ElevatorBox : MonoBehaviour
default: default:
break; break;
} }
StartCoroutine(LiftTransferSequence()); StartCoroutine(LiftTransferSequence());
} }
@@ -169,6 +180,8 @@ public class ElevatorBox : MonoBehaviour
// Was it a player, that exited? // Was it a player, that exited?
XROrigin exitedPlayerVR = other.GetComponent<XROrigin>(); XROrigin exitedPlayerVR = other.GetComponent<XROrigin>();
KbmController exitedPlayerKbm = other.GetComponent<KbmController>(); KbmController exitedPlayerKbm = other.GetComponent<KbmController>();
XRPlayerMirror networkPlayerDisplay = other.GetComponentInParent<XRPlayerMirror>();
if (exitedPlayerVR != null) if (exitedPlayerVR != null)
{ {
removeChild(exitedPlayerVR); removeChild(exitedPlayerVR);
@@ -177,6 +190,10 @@ public class ElevatorBox : MonoBehaviour
{ {
exitedPlayerKbm.transform.SetParent(null); exitedPlayerKbm.transform.SetParent(null);
} }
else if (networkPlayerDisplay != null)
{
//don't do any parenting but don't halt the function
}
else else
return; return;
@@ -263,6 +280,7 @@ public class ElevatorBox : MonoBehaviour
private IEnumerator LiftTransferSequence() private IEnumerator LiftTransferSequence()
{ {
Debug.Log("Started Lidt transfer sequence");
yield return StartCoroutine(CloseDoors()); yield return StartCoroutine(CloseDoors());
yield return StartCoroutine(MoveToFloor(targetFloor)); yield return StartCoroutine(MoveToFloor(targetFloor));
} }
@@ -295,7 +313,7 @@ public class ElevatorBox : MonoBehaviour
private IEnumerator CloseDoors() private IEnumerator CloseDoors()
{ {
//if (state == ElevatorState.AwaitingPassengers) { //if (state == ElevatorState.AwaitingPassengers) {
//Debug.Log("Closing doors"); Debug.Log("Closing doors");
if (Vector3.Distance(leftDoor.transform.position, leftDoorClosedPos.position) < 0.01f) if (Vector3.Distance(leftDoor.transform.position, leftDoorClosedPos.position) < 0.01f)
yield break; yield break;

View File

@@ -1,9 +1,10 @@
using FishNet.Object;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Unity.XR.CoreUtils; using Unity.XR.CoreUtils;
using UnityEngine; using UnityEngine;
public class ElevatorOuter : MonoBehaviour public class ElevatorOuter : NetworkBehaviour
{ {
public ElevatorBox box; public ElevatorBox box;
@@ -32,7 +33,7 @@ public class ElevatorOuter : MonoBehaviour
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
{ {
Debug.Log("Something entered call area"); Debug.Log("Something entered call area");
if (other.GetComponent<XROrigin>() == null && other.GetComponent<KbmController>() == null) return; if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
StartCoroutine(box.callElevator(floor)); StartCoroutine(box.callElevator(floor));
Debug.Log("Player entered call area"); Debug.Log("Player entered call area");
} }
@@ -40,7 +41,7 @@ public class ElevatorOuter : MonoBehaviour
private void OnTriggerExit(Collider other) private void OnTriggerExit(Collider other)
{ {
Debug.Log("Something entered call area"); Debug.Log("Something entered call area");
if (other.GetComponent<XROrigin>() == null && other.GetComponent<KbmController>() == null) return; if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
box.interestExpired(); box.interestExpired();
Debug.Log("Player exited call area"); Debug.Log("Player exited call area");
} }

View File

@@ -55,7 +55,7 @@ namespace _PROJECT.NewHandPresence
var devices = new List<InputDevice>(); var devices = new List<InputDevice>();
InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices); InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);
Debug.Log("Found devices: " + devices.Count); //Debug.Log("Found devices: " + devices.Count);
if (devices.Count <= 0) return; if (devices.Count <= 0) return;

View File

@@ -1458,8 +1458,8 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 4219249119743129064} - {fileID: 4219249119743129064}
- {fileID: 3078516333947655590}
- {fileID: 2833299236575698182} - {fileID: 2833299236575698182}
- {fileID: 3078516333947655590}
m_Father: {fileID: 1938936874169646409} m_Father: {fileID: 1938936874169646409}
m_RootOrder: -1 m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1692,7 +1692,6 @@ GameObject:
- component: {fileID: 150987804393607111} - component: {fileID: 150987804393607111}
- component: {fileID: 2849620166313326850} - component: {fileID: 2849620166313326850}
- component: {fileID: 3623653364064856318} - component: {fileID: 3623653364064856318}
- component: {fileID: 6605356447225771655}
m_Layer: 0 m_Layer: 0
m_Name: NetworkManagerUI m_Name: NetworkManagerUI
m_TagString: Untagged m_TagString: Untagged
@@ -1791,29 +1790,6 @@ AudioListener:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8920648335286241163} m_GameObject: {fileID: 8920648335286241163}
m_Enabled: 1 m_Enabled: 1
--- !u!114 &6605356447225771655
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8920648335286241163}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0be1f6fa249e2b74d80c57af214b930d, type: 3}
m_Name:
m_EditorClassIdentifier:
VRToggle: {fileID: 0}
startPlayingButton: {fileID: 4409105029378525441}
reloadButton: {fileID: 3248072787155925101}
joinMultiplayerButton: {fileID: 7057699864170177475}
serverListContainer: {fileID: 6604224998162932651}
IPButton: {fileID: 8799561993934626415}
statusText: {fileID: 2762709333159616741}
quitButton: {fileID: 856744223094475457}
networkDiscovery: {fileID: 0}
uiCamera: {fileID: 0}
placeholderAudioListener: {fileID: 0}
--- !u!1 &8930421849167053048 --- !u!1 &8930421849167053048
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

BIN
Build.zip LFS

Binary file not shown.