feat: basic online working with relay
This commit is contained in:
@@ -235,7 +235,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3727451710788063110}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 89875cdc57c54474a8a74efd9b2a3b5d, type: 3}
|
||||
m_Name:
|
||||
@@ -456,7 +456,6 @@ MonoBehaviour:
|
||||
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_RequiresDepthTexture: 0
|
||||
m_RequiresColorTexture: 0
|
||||
m_Version: 2
|
||||
m_TaaSettings:
|
||||
m_Quality: 3
|
||||
m_FrameInfluence: 0.1
|
||||
@@ -464,6 +463,7 @@ MonoBehaviour:
|
||||
m_MipBias: 0
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
m_Version: 2
|
||||
--- !u!114 &8677805350076133661
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -18,7 +18,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &673391980113178687
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -27,7 +27,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3608368543505542050}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 9.256327, y: -15.74262, z: 7.6148796}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
@@ -50,7 +50,7 @@ MonoBehaviour:
|
||||
NetworkConfig:
|
||||
ProtocolVersion: 0
|
||||
NetworkTransport: {fileID: 8202239970190248966}
|
||||
PlayerPrefab: {fileID: 0}
|
||||
PlayerPrefab: {fileID: 2757828562731694833, guid: 091cfac8be4c5a144a0b8997a9f1ff28, type: 3}
|
||||
Prefabs:
|
||||
NetworkPrefabsLists:
|
||||
- {fileID: 11400000, guid: 935babab2affb8f4683610c7e463c3ad, type: 2}
|
||||
@@ -69,7 +69,7 @@ MonoBehaviour:
|
||||
LoadSceneTimeOut: 120
|
||||
SpawnTimeout: 10
|
||||
EnableNetworkLogs: 1
|
||||
NetworkTopology: 0
|
||||
NetworkTopology: 1
|
||||
UseCMBService: 0
|
||||
AutoSpawnPlayerPrefabClientSide: 1
|
||||
NetworkMessageMetrics: 1
|
||||
@@ -113,7 +113,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3608368543505542050}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 31709e0224b48e24b8e5311541392a97, type: 3}
|
||||
m_Name:
|
||||
|
||||
@@ -120,6 +120,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7329826263822975762}
|
||||
- component: {fileID: 2538182172493791937}
|
||||
- component: {fileID: 7494367001870099223}
|
||||
- component: {fileID: 8163344541298437235}
|
||||
- component: {fileID: 679199079481597207}
|
||||
@@ -129,7 +130,6 @@ GameObject:
|
||||
- component: {fileID: 2129000951396423518}
|
||||
- component: {fileID: 2842793574603981349}
|
||||
- component: {fileID: 43868462096200776}
|
||||
- component: {fileID: 2538182172493791937}
|
||||
- component: {fileID: 6067609290387865387}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
@@ -154,6 +154,31 @@ Transform:
|
||||
- {fileID: 2655796284435897345}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2538182172493791937
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2757828562731694833}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkObject
|
||||
GlobalObjectIdHash: 3816484910
|
||||
InScenePlacedSourceGlobalObjectIdHash: 0
|
||||
DeferredDespawnTick: 0
|
||||
Ownership: 1
|
||||
AlwaysReplicateAsRoot: 0
|
||||
SynchronizeTransform: 1
|
||||
ActiveSceneSynchronization: 0
|
||||
SceneMigrationSynchronization: 1
|
||||
SpawnWithObservers: 1
|
||||
DontDestroyWithOwner: 0
|
||||
AutoObjectParentSync: 1
|
||||
SyncOwnerTransformWhenParented: 1
|
||||
AllowOwnerToParent: 0
|
||||
--- !u!114 &7494367001870099223
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -166,6 +191,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 0c0da0317d344ea49b810f0010efefa8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
controls: {fileID: 0}
|
||||
camera: {fileID: 0}
|
||||
--- !u!114 &8163344541298437235
|
||||
@@ -433,7 +459,7 @@ MonoBehaviour:
|
||||
m_ActionEvents: []
|
||||
m_NeverAutoSwitchControlSchemes: 1
|
||||
m_DefaultControlScheme: Controller
|
||||
m_DefaultActionMap: b2eefcc8-f0a6-4007-854d-f0b59159e624
|
||||
m_DefaultActionMap: In-Game
|
||||
m_SplitScreenIndex: -1
|
||||
m_Camera: {fileID: 0}
|
||||
--- !u!143 &2106585328495276993
|
||||
@@ -556,31 +582,6 @@ MonoBehaviour:
|
||||
Radius: 0.5
|
||||
targetGroup: {fileID: 0}
|
||||
lockOnDocument: {fileID: 0}
|
||||
--- !u!114 &2538182172493791937
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2757828562731694833}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkObject
|
||||
GlobalObjectIdHash: 3816484910
|
||||
InScenePlacedSourceGlobalObjectIdHash: 0
|
||||
DeferredDespawnTick: 0
|
||||
Ownership: 1
|
||||
AlwaysReplicateAsRoot: 0
|
||||
SynchronizeTransform: 1
|
||||
ActiveSceneSynchronization: 0
|
||||
SceneMigrationSynchronization: 1
|
||||
SpawnWithObservers: 1
|
||||
DontDestroyWithOwner: 0
|
||||
AutoObjectParentSync: 1
|
||||
SyncOwnerTransformWhenParented: 1
|
||||
AllowOwnerToParent: 0
|
||||
--- !u!114 &6067609290387865387
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -596,7 +597,7 @@ MonoBehaviour:
|
||||
ShowTopMostFoldoutHeaderGroup: 1
|
||||
NetworkTransformExpanded: 0
|
||||
AutoOwnerAuthorityTickOffset: 1
|
||||
PositionInterpolationType: 0
|
||||
PositionInterpolationType: 2
|
||||
RotationInterpolationType: 0
|
||||
ScaleInterpolationType: 0
|
||||
PositionLerpSmoothing: 1
|
||||
|
||||
@@ -255,6 +255,41 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 12023376}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &16776950
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 16776951}
|
||||
m_Layer: 5
|
||||
m_Name: Online Controls
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &16776951
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 16776950}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1433518867}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!43 &55045520
|
||||
Mesh:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -934,6 +969,9 @@ PrefabInstance:
|
||||
- targetCorrespondingSourceObject: {fileID: 4906743167862811726, guid: 86fe521c4bae13c4ab1ad5a357fe8d47, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1293873423}
|
||||
- targetCorrespondingSourceObject: {fileID: 4906743167862811726, guid: 86fe521c4bae13c4ab1ad5a357fe8d47, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 16776951}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 86fe521c4bae13c4ab1ad5a357fe8d47, type: 3}
|
||||
--- !u!1 &100788157
|
||||
@@ -1681,6 +1719,67 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 336882625}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &394357389 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 3727451710788063110, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
m_PrefabInstance: {fileID: 870221777}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &394357396 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 4828207810450504966, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
m_PrefabInstance: {fileID: 870221777}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 394357389}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3b5d7c088409d9a40b7b09aa707777f8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &394357398
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 394357389}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 058c862723373ca43913637463aff84a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Core::CustomInputHandler
|
||||
ScanRecursively: 1
|
||||
SuppressInputWhileBlending: 1
|
||||
IgnoreTimeScale: 0
|
||||
m_ControllerManager:
|
||||
Controllers:
|
||||
- Name: Look Orbit X
|
||||
Owner: {fileID: 394357396}
|
||||
Enabled: 1
|
||||
Input:
|
||||
Input: {fileID: 6185001796860367008, guid: 94c7611bb3f64b248940847af54844cf, type: 3}
|
||||
InputValue: 0
|
||||
Driver:
|
||||
AccelTime: 0
|
||||
DecelTime: 0
|
||||
- Name: Look Orbit Y
|
||||
Owner: {fileID: 394357396}
|
||||
Enabled: 1
|
||||
Input:
|
||||
Input: {fileID: 6185001796860367008, guid: 94c7611bb3f64b248940847af54844cf, type: 3}
|
||||
InputValue: 0
|
||||
Driver:
|
||||
AccelTime: 0
|
||||
DecelTime: 0
|
||||
- Name: Orbit Scale
|
||||
Owner: {fileID: 394357396}
|
||||
Enabled: 1
|
||||
Input:
|
||||
Input: {fileID: 6185001796860367008, guid: 94c7611bb3f64b248940847af54844cf, type: 3}
|
||||
InputValue: 0
|
||||
Driver:
|
||||
AccelTime: 0
|
||||
DecelTime: 0
|
||||
PlayerInput: {fileID: 0}
|
||||
--- !u!1001 &400326425
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2442,7 +2541,10 @@ PrefabInstance:
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 3727451710788063110, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
insertIndex: 6
|
||||
addedObject: {fileID: 394357398}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 6ae1b39ffbe1f0f468d521bb08a8b547, type: 3}
|
||||
--- !u!1 &927616996
|
||||
GameObject:
|
||||
@@ -6461,18 +6563,6 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 541335868644022067, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 541335868644022067, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: NetworkConfig.PlayerPrefab
|
||||
value:
|
||||
objectReference: {fileID: 2757828562731694833, guid: 091cfac8be4c5a144a0b8997a9f1ff28, type: 3}
|
||||
- target: {fileID: 541335868644022067, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: NetworkConfig.NetworkTopology
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 673391980113178687, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 9.256327
|
||||
@@ -6517,22 +6607,6 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: NetworkManager
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3608368543505542050, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3971766729977841875, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8202239970190248966, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8202239970190248966, guid: 222e4e6c5bda2b64da9c38abf6dc55bb, type: 3}
|
||||
propertyPath: m_ProtocolType
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Reset.Core.Tools;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Users;
|
||||
@@ -12,7 +13,17 @@ namespace Reset{
|
||||
public static GameObject Input;
|
||||
public static SessionManager Session;
|
||||
|
||||
public static GameObject Player;
|
||||
private static GameObject player;
|
||||
|
||||
public static GameObject Player{
|
||||
get{ return player; }
|
||||
set{ player = value; }
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void Reset(){
|
||||
player = null;
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void PopulateSceneReferences(){
|
||||
@@ -35,6 +46,17 @@ namespace Reset{
|
||||
playerUser = InputUser.PerformPairingWithDevice(device, playerUser, InputUserPairingOptions.UnpairCurrentDevicesFromUser);
|
||||
}
|
||||
|
||||
public static GameObject FindNewPlayer(){
|
||||
var allPlayers = GameObject.FindGameObjectsWithTag("Player");
|
||||
for (int i = 0; i < allPlayers.Length; i++) {
|
||||
if (allPlayers[i].GetComponent<Player>() && allPlayers[i].GetComponent<NetworkObject>().IsLocalPlayer) {
|
||||
return allPlayers[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void RequestNewController(){
|
||||
try {
|
||||
GameObject.Find("Input Selector").GetComponent<InputFinder>().AwaitNewInput();
|
||||
|
||||
@@ -6,6 +6,7 @@ using Reset;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UIElements;
|
||||
using Vector2 = UnityEngine.Vector2;
|
||||
@@ -44,8 +45,7 @@ public class LockOnManager : MonoBehaviour{
|
||||
private Label elementLabelName;
|
||||
private VisualElement elementRoot;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start(){
|
||||
private void Awake(){
|
||||
// Register as singleton
|
||||
if (Instance == null) {
|
||||
Instance = this;
|
||||
@@ -57,11 +57,10 @@ public class LockOnManager : MonoBehaviour{
|
||||
// References from camera
|
||||
targetGroup = GameManager.Camera.transform.Find("Target Group").GetComponent<CinemachineTargetGroup>();
|
||||
lockOnDocument = GameManager.UI.transform.Find("Lock On").GetComponent<UIDocument>();
|
||||
}
|
||||
|
||||
// Set the camera's target as the player
|
||||
targetGroup.Targets.Add(new CinemachineTargetGroup.Target{Object = transform, Radius = 3.5f, Weight = 1f});
|
||||
GameManager.Camera.transform.Find("Cinemachine").GetComponent<CinemachineCamera>().Target.TrackingTarget = transform;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start(){
|
||||
// Quick check for things in lock-on target that aren't lock-onable
|
||||
if (mainTarget != null && mainTarget.gameObject.GetComponent<ILockOnTarget>() == null) {
|
||||
mainTarget.gameObject.AddComponent<GenericLockOnTarget>();
|
||||
@@ -81,6 +80,18 @@ public class LockOnManager : MonoBehaviour{
|
||||
}
|
||||
}
|
||||
|
||||
public void AttachCamera(GameObject target){
|
||||
targetGroup = GameManager.Camera.transform.Find("Target Group").GetComponent<CinemachineTargetGroup>();
|
||||
Debug.Log($"{GameManager.Camera}");
|
||||
|
||||
// Set the camera's target as the player
|
||||
targetGroup.Targets.Add(new CinemachineTargetGroup.Target{Object = target.transform, Radius = 3.5f, Weight = 1f});
|
||||
GameManager.Camera.transform.Find("Cinemachine").GetComponent<CinemachineCamera>().Target.TrackingTarget = target.transform;
|
||||
GameManager.Camera.transform.Find("Cinemachine").GetComponent<CustomInputHandler>().PlayerInput =
|
||||
GetComponent<PlayerInput>();
|
||||
GameManager.Camera.transform.Find("Cinemachine").GetComponent<CustomInputHandler>().AddEvents();
|
||||
}
|
||||
|
||||
void Update(){
|
||||
if (mainTarget != null && mainTarget.gameObject.GetComponent<ILockOnTarget>() == null) {
|
||||
mainTarget.gameObject.AddComponent<GenericLockOnTarget>();
|
||||
|
||||
@@ -13,6 +13,7 @@ using Unity.Services.Core;
|
||||
public class SessionManager : MonoBehaviour{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start(){
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
79
Assets/Scripts/Player/CustomInputHandler.cs
Normal file
79
Assets/Scripts/Player/CustomInputHandler.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using Unity.Cinemachine;
|
||||
|
||||
// This class receives input from a PlayerInput component and disptaches it
|
||||
// to the appropriate Cinemachine InputAxis. The playerInput component should
|
||||
// be on the same GameObject, or specified in the PlayerInput field.
|
||||
class CustomInputHandler : InputAxisControllerBase<CustomInputHandler.Reader>
|
||||
{
|
||||
[Header("Input Source Override")]
|
||||
public PlayerInput PlayerInput;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// // When the PlayerInput receives an input, send it to all the controllers
|
||||
// if (PlayerInput == null)
|
||||
// TryGetComponent(out PlayerInput);
|
||||
// if (PlayerInput == null)
|
||||
// Debug.LogError("Cannot find PlayerInput component");
|
||||
// else
|
||||
// {
|
||||
// PlayerInput.notificationBehavior = PlayerNotifications.InvokeCSharpEvents;
|
||||
// PlayerInput.onActionTriggered += (value) =>
|
||||
// {
|
||||
// for (var i = 0; i < Controllers.Count; i++)
|
||||
// Controllers[i].Input.ProcessInput(value.action);
|
||||
// };
|
||||
// }
|
||||
}
|
||||
|
||||
// We process user input on the Update clock
|
||||
void Update()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
UpdateControllers();
|
||||
Controllers[0].Input.ProcessInput(PlayerInput);
|
||||
Controllers[1].Input.ProcessInput(PlayerInput);
|
||||
}
|
||||
|
||||
public void AddEvents(){
|
||||
// // PlayerInput.notificationBehavior = PlayerNotifications.InvokeCSharpEvents;
|
||||
// += (value) =>
|
||||
// {
|
||||
// for (var i = 0; i < Controllers.Count; i++)
|
||||
// Controllers[i].Input.ProcessInput(value.action);
|
||||
// };
|
||||
}
|
||||
|
||||
// Controllers will be instances of this class.
|
||||
[Serializable]
|
||||
public class Reader : IInputAxisReader
|
||||
{
|
||||
public InputActionReference Input;
|
||||
Vector2 m_Value; // the cached value of the input
|
||||
|
||||
public void ProcessInput(PlayerInput input){
|
||||
|
||||
// // If it's my action then cache the new value
|
||||
// if (Input != null && Input.action.id == action.id)
|
||||
// {
|
||||
// if (action.expectedControlType == "Vector2")
|
||||
// m_Value = action.ReadValue<Vector2>();
|
||||
// else
|
||||
// m_Value.x = m_Value.y = action.ReadValue<float>();
|
||||
// }
|
||||
|
||||
m_Value = input.actions["Look"].ReadValue<Vector2>();
|
||||
m_Value.x *= 200f;
|
||||
m_Value.y *= -100f;
|
||||
}
|
||||
|
||||
// IInputAxisReader interface: Called by the framework to read the input value
|
||||
public float GetValue(UnityEngine.Object context, IInputAxisOwner.AxisDescriptor.Hints hint)
|
||||
{
|
||||
return (hint == IInputAxisOwner.AxisDescriptor.Hints.Y ? m_Value.y : m_Value.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Player/CustomInputHandler.cs.meta
Normal file
2
Assets/Scripts/Player/CustomInputHandler.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 058c862723373ca43913637463aff84a
|
||||
@@ -1,26 +1,55 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Reset;
|
||||
using Reset.Core.Tools;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Netcode;
|
||||
|
||||
|
||||
public class Player : MonoBehaviour{
|
||||
public class Player : NetworkBehaviour{
|
||||
[HideInInspector] public PlayerControls controls;
|
||||
[HideInInspector] public new PlayerCamera camera;
|
||||
|
||||
void Awake(){
|
||||
GameManager.Player = gameObject;
|
||||
controls = GetComponent<PlayerControls>();
|
||||
GameManager.RequestNewController();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
Debug.Log(GameManager.Player);
|
||||
if (!NetworkManager.Singleton.IsConnectedClient && !NetworkManager.Singleton.IsHost) {
|
||||
Attach();
|
||||
} else {
|
||||
StartCoroutine(WaitForOnline());
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WaitForOnline(){
|
||||
while (!NetworkManager.Singleton.didAwake) {
|
||||
Debug.Log("waiting");
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Debug.Log($"{IsHost}, {IsClient}, {IsLocalPlayer}");
|
||||
if (IsLocalPlayer){
|
||||
GameManager.Player = gameObject;
|
||||
Attach();
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach(){
|
||||
if (GameManager.Player == gameObject){
|
||||
GameManager.RequestNewController();
|
||||
GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNetworkPostSpawn(){
|
||||
// GetComponent<LockOnManager>().AttachCamera(gameObject);
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,9 @@ using UnityEngine.UIElements;
|
||||
using NodeCanvas;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion;
|
||||
using Reset;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Cinemachine;
|
||||
|
||||
public class PlayerControls : MonoBehaviour{
|
||||
// References
|
||||
@@ -63,6 +65,9 @@ public class PlayerControls : MonoBehaviour{
|
||||
public void OnLook(InputValue value){
|
||||
rawLookInput.x = value.Get<Vector2>().x;
|
||||
rawLookInput.y = value.Get<Vector2>().y;
|
||||
|
||||
// GameManager.Camera.transform.Find("Cinemachine").GetComponent<CustomInputHandler>().Controllers[0].InputValue = rawLookInput.x * 200;
|
||||
// GameManager.Camera.transform.Find("Cinemachine").GetComponent<CustomInputHandler>().Controllers[1].InputValue = rawLookInput.y * 100;
|
||||
}
|
||||
|
||||
public void OnSprint(){
|
||||
|
||||
Reference in New Issue
Block a user