From 67eff07ace14f0cecaee481b3b3ccf1043ea9f09 Mon Sep 17 00:00:00 2001 From: sebastianhampel1 Date: Thu, 15 Jun 2023 11:34:45 -0400 Subject: [PATCH] Multiplayer Shooting Support --- Assets/DefaultPrefabObjects.asset | 3 + .../Levels/Level0/CeilLightMaterial.mat | 2 +- Assets/Prefabs/Astronaut/Astronaut.prefab | 16 ++-- .../Prefabs/GunPrefabs/FlareParticle.prefab | 73 +++++++++++++++++++ Assets/Prefabs/GunPrefabs/Pistol1.prefab | 3 + Assets/Prefabs/Items/LowPolyScifiGun.prefab | 16 ++++ Assets/Scenes/Levels/Level0.unity | 64 ++++++++++++++++ Assets/Scripts/Item/Pistol/PistolComponent.cs | 7 +- Assets/Scripts/SerializedObjects/GameState.cs | 1 + .../SerializedObjects/GlobalReferences.cs | 13 ++++ .../GlobalReferences.cs.meta | 11 +++ ...zzle_2020.3_HDRP_v1.0.1.unitypackage.meta} | 2 +- ...Muzzle_2020.3_URP_v1.0.1.unitypackage.meta | 7 ++ 13 files changed, 209 insertions(+), 9 deletions(-) create mode 100644 Assets/Scripts/SerializedObjects/GlobalReferences.cs create mode 100644 Assets/Scripts/SerializedObjects/GlobalReferences.cs.meta rename Assets/{Packages/FishNet/Plugins/FishySteamworks/SteamManager.unitypackage.meta => VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_HDRP_v1.0.1.unitypackage.meta} (74%) create mode 100644 Assets/VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_URP_v1.0.1.unitypackage.meta diff --git a/Assets/DefaultPrefabObjects.asset b/Assets/DefaultPrefabObjects.asset index 5fe5ca5..3dab808 100644 --- a/Assets/DefaultPrefabObjects.asset +++ b/Assets/DefaultPrefabObjects.asset @@ -14,6 +14,9 @@ MonoBehaviour: m_EditorClassIdentifier: _prefabs: - {fileID: 5498159848629933595, guid: 10110e55c50520d42a4601f2a7d6542f, type: 3} + - {fileID: 1069525110278255243, guid: 5e611af8f39b09a4f9b479a29f3460ff, type: 3} + - {fileID: -2750772001946868067, guid: 396e7ba93ef9d4147a6a6c09b1abe39d, type: 3} + - {fileID: -3687221924445419690, guid: 52ba61e86784ff5458c6685514d6d6c8, type: 3} - {fileID: -3690528308152583234, guid: 148456ca1eee0994eb0165cb943e8322, type: 3} - {fileID: 4512293259955182956, guid: 300370bdf7819da41937e0beac65b32c, type: 3} - {fileID: 233110740096973419, guid: e05b94df3e7783a48ac1ed2d12a71774, type: 3} diff --git a/Assets/Materials/Levels/Level0/CeilLightMaterial.mat b/Assets/Materials/Levels/Level0/CeilLightMaterial.mat index 354b23f..715777f 100644 --- a/Assets/Materials/Levels/Level0/CeilLightMaterial.mat +++ b/Assets/Materials/Levels/Level0/CeilLightMaterial.mat @@ -206,7 +206,7 @@ Material: - _StencilWriteMask: 6 - _StencilWriteMaskDepth: 8 - _StencilWriteMaskGBuffer: 14 - - _StencilWriteMaskMV: 40 + - _StencilWriteMaskMV: 42 - _SubsurfaceMask: 1 - _SupportDecals: 1 - _SurfaceType: 0 diff --git a/Assets/Prefabs/Astronaut/Astronaut.prefab b/Assets/Prefabs/Astronaut/Astronaut.prefab index c79545d..529efa0 100644 --- a/Assets/Prefabs/Astronaut/Astronaut.prefab +++ b/Assets/Prefabs/Astronaut/Astronaut.prefab @@ -44,7 +44,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3847c9aa2dda4d64f84842c3cc880d7e, type: 3} m_Name: m_EditorClassIdentifier: - _componentIndexCache: 3 + _componentIndexCache: 4 _addedNetworkObject: {fileID: 5498159848629933595} _networkObjectCache: {fileID: 5498159848629933595} cam: {fileID: 0} @@ -1738,7 +1738,7 @@ MonoBehaviour: noiseManager: {fileID: 1000589094} shift: {fileID: 0} isDead: 0 - manager: {fileID: 0} + manager: {fileID: 11400000, guid: 11aa6a76246138741ae6aeda5ffa9a94, type: 2} --- !u!1 &1542395871221419507 GameObject: m_ObjectHideFlags: 0 @@ -5331,6 +5331,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 86fd72b889d47804e844e0bc9c04218d, type: 3} m_Name: m_EditorClassIdentifier: + _componentIndexCache: 1 + _addedNetworkObject: {fileID: 5498159848629933595} + _networkObjectCache: {fileID: 5498159848629933595} health: 5 maxHealth: 5 stamina: 20 @@ -5404,8 +5407,9 @@ MonoBehaviour: k__BackingField: {fileID: 0} _networkBehaviours: - {fileID: 2821278824672803001} + - {fileID: 1000589095} - {fileID: 3207797364320485426} - - {fileID: 0} + - {fileID: 558651035056782169} - {fileID: 165371622} k__BackingField: {fileID: 0} k__BackingField: [] @@ -5432,7 +5436,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a2836e36774ca1c4bbbee976e17b649c, type: 3} m_Name: m_EditorClassIdentifier: - _componentIndexCache: 1 + _componentIndexCache: 2 _addedNetworkObject: {fileID: 5498159848629933595} _networkObjectCache: {fileID: 5498159848629933595} _componentConfiguration: 1 @@ -5474,9 +5478,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e8cac635f24954048aad3a6ff9110beb, type: 3} m_Name: m_EditorClassIdentifier: - _componentIndexCache: 255 + _componentIndexCache: 3 _addedNetworkObject: {fileID: 5498159848629933595} - _networkObjectCache: {fileID: 0} + _networkObjectCache: {fileID: 5498159848629933595} IgnoredParameters: [] _animator: {fileID: 5567518431331631942} _smoothFloats: 1 diff --git a/Assets/Prefabs/GunPrefabs/FlareParticle.prefab b/Assets/Prefabs/GunPrefabs/FlareParticle.prefab index d721bea..c7ec1ed 100644 --- a/Assets/Prefabs/GunPrefabs/FlareParticle.prefab +++ b/Assets/Prefabs/GunPrefabs/FlareParticle.prefab @@ -14,6 +14,8 @@ GameObject: - component: {fileID: 4575714109450776058} - component: {fileID: -3126027469558985513} - component: {fileID: -2166122047152726235} + - component: {fileID: 1069525110278255243} + - component: {fileID: 8789794426191792349} m_Layer: 0 m_Name: FlareParticle m_TagString: Untagged @@ -132,6 +134,77 @@ MonoBehaviour: type: flare damageRange: 3 damageMagnitude: 1 +--- !u!114 &1069525110278255243 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4575714109450776061} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: {fileID: 0} + _networkBehaviours: [] + k__BackingField: {fileID: 0} + k__BackingField: [] + _isNetworked: 1 + _isGlobal: 0 + _initializeOrder: 0 + _defaultDespawnType: 0 + NetworkObserver: {fileID: 0} + k__BackingField: 0 + k__BackingField: 0 + _scenePathHash: 0 + k__BackingField: 0 + k__BackingField: 17677934213645310587 + _sceneNetworkObjects: [] +--- !u!114 &8789794426191792349 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4575714109450776061} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a2836e36774ca1c4bbbee976e17b649c, type: 3} + m_Name: + m_EditorClassIdentifier: + _componentIndexCache: 255 + _addedNetworkObject: {fileID: 1069525110278255243} + _networkObjectCache: {fileID: 0} + _componentConfiguration: 0 + _synchronizeParent: 0 + _packing: + Position: 1 + Rotation: 1 + Scale: 0 + _interpolation: 2 + _extrapolation: 2 + _enableTeleport: 0 + _teleportThreshold: 1 + _clientAuthoritative: 1 + _sendToOwner: 1 + _synchronizePosition: 1 + _positionSnapping: + X: 0 + Y: 0 + Z: 0 + _synchronizeRotation: 1 + _rotationSnapping: + X: 0 + Y: 0 + Z: 0 + _synchronizeScale: 1 + _scaleSnapping: + X: 0 + Y: 0 + Z: 0 --- !u!1 &4575714110311104494 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/GunPrefabs/Pistol1.prefab b/Assets/Prefabs/GunPrefabs/Pistol1.prefab index 94c3565..4be288c 100644 --- a/Assets/Prefabs/GunPrefabs/Pistol1.prefab +++ b/Assets/Prefabs/GunPrefabs/Pistol1.prefab @@ -514,6 +514,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a0bc8aa373bfbe44e91f0625324088be, type: 3} m_Name: m_EditorClassIdentifier: + _componentIndexCache: 255 + _addedNetworkObject: {fileID: 0} + _networkObjectCache: {fileID: 0} aimMode: 2 targetingLight: {fileID: 935129114346117162} targetObjectPrefab: {fileID: 7083481049935262560, guid: 25e7708870a1a78479d6e4df73bec788, type: 3} diff --git a/Assets/Prefabs/Items/LowPolyScifiGun.prefab b/Assets/Prefabs/Items/LowPolyScifiGun.prefab index b76a382..2953bce 100644 --- a/Assets/Prefabs/Items/LowPolyScifiGun.prefab +++ b/Assets/Prefabs/Items/LowPolyScifiGun.prefab @@ -382,5 +382,21 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a0bc8aa373bfbe44e91f0625324088be, type: 3} m_Name: m_EditorClassIdentifier: + _componentIndexCache: 255 + _addedNetworkObject: {fileID: 0} + _networkObjectCache: {fileID: 0} + aimMode: 2 targetingLight: {fileID: 7403853081934682846} targetObjectPrefab: {fileID: 7083481049935262560, guid: 25e7708870a1a78479d6e4df73bec788, type: 3} + projectilePrefab: {fileID: 0} + projectileName: + bulletSpawnPoint: {fileID: 0} + firePower: 20 + maxProjectileDuration: 5 + maxTargetObjDistance: 15 + shootEffect: {fileID: 0} + shootLight: {fileID: 0} + shootLightDuration: 0.1 + ignoreLayers: + serializedVersion: 2 + m_Bits: 0 diff --git a/Assets/Scenes/Levels/Level0.unity b/Assets/Scenes/Levels/Level0.unity index f685bc3..a84313c 100644 --- a/Assets/Scenes/Levels/Level0.unity +++ b/Assets/Scenes/Levels/Level0.unity @@ -1798,6 +1798,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 7054175667404048554, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: state + value: + objectReference: {fileID: 11400000, guid: 11aa6a76246138741ae6aeda5ffa9a94, type: 2} - target: {fileID: 7054175669031773906, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} propertyPath: m_Name value: BasicLevel0 @@ -1846,6 +1850,30 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 7274624881599411862, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.w + value: 0.99938023 + objectReference: {fileID: 0} + - target: {fileID: 7274624881599411862, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.x + value: -0.03520201 + objectReference: {fileID: 0} + - target: {fileID: 7274624881599411862, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.y + value: -0.00000001750598 + objectReference: {fileID: 0} + - target: {fileID: 7274624881599411862, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.z + value: 0.000000002846753 + objectReference: {fileID: 0} + - target: {fileID: 7274624882445554639, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.w + value: 0.9985746 + objectReference: {fileID: 0} + - target: {fileID: 7274624882445554639, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.x + value: -0.053374406 + objectReference: {fileID: 0} - target: {fileID: 7274624882445554639, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} propertyPath: m_LocalRotation.y value: -3.9161743e-10 @@ -1854,6 +1882,38 @@ PrefabInstance: propertyPath: m_LocalRotation.z value: 5.6392228e-11 objectReference: {fileID: 0} + - target: {fileID: 7274624882710027854, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.w + value: 0.99744195 + objectReference: {fileID: 0} + - target: {fileID: 7274624882710027854, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.x + value: -0.07148121 + objectReference: {fileID: 0} + - target: {fileID: 7274624882710027854, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.y + value: -0.000000017597836 + objectReference: {fileID: 0} + - target: {fileID: 7274624882710027854, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.z + value: 0.0000000022089703 + objectReference: {fileID: 0} + - target: {fileID: 7274624883331524490, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalPosition.y + value: 0.82000005 + objectReference: {fileID: 0} + - target: {fileID: 7274624883331524490, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalPosition.z + value: -3 + objectReference: {fileID: 0} + - target: {fileID: 7274624883331524490, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.w + value: 0.9989963 + objectReference: {fileID: 0} + - target: {fileID: 7274624883331524490, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: m_LocalRotation.x + value: 0.04479234 + objectReference: {fileID: 0} - target: {fileID: 7274624883331524490, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} propertyPath: m_LocalRotation.y value: 0.0000000344453 @@ -1862,6 +1922,10 @@ PrefabInstance: propertyPath: m_LocalRotation.z value: -0.0000000015444355 objectReference: {fileID: 0} + - target: {fileID: 9048691461878283844, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} + propertyPath: manager + value: + objectReference: {fileID: 11400000, guid: 11aa6a76246138741ae6aeda5ffa9a94, type: 2} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 3cbb87b9c7b0a01458108d45dc4eee05, type: 3} --- !u!1 &191404492 diff --git a/Assets/Scripts/Item/Pistol/PistolComponent.cs b/Assets/Scripts/Item/Pistol/PistolComponent.cs index 22ab483..5fe4518 100644 --- a/Assets/Scripts/Item/Pistol/PistolComponent.cs +++ b/Assets/Scripts/Item/Pistol/PistolComponent.cs @@ -1,9 +1,11 @@ using UnityEngine; using UnityEngine.VFX; +using FishNet.Object; +using FishNet; namespace Item { - public class PistolComponent : MonoBehaviour + public class PistolComponent : NetworkBehaviour { public enum AimMode { @@ -130,7 +132,10 @@ namespace Item { shootLightDuration = 0; shootLight.gameObject.SetActive(true); + var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); + InstanceFinder.ServerManager.Spawn(projectile); + projectile.transform.localPosition = Vector3.zero; projectile.transform.localEulerAngles = Vector3.zero; projectile.transform.localScale = Vector3.one; diff --git a/Assets/Scripts/SerializedObjects/GameState.cs b/Assets/Scripts/SerializedObjects/GameState.cs index 6c7ad81..d364ba6 100644 --- a/Assets/Scripts/SerializedObjects/GameState.cs +++ b/Assets/Scripts/SerializedObjects/GameState.cs @@ -9,6 +9,7 @@ namespace Scriptable { [HideInInspector] public bool IsPaused = false; + } } diff --git a/Assets/Scripts/SerializedObjects/GlobalReferences.cs b/Assets/Scripts/SerializedObjects/GlobalReferences.cs new file mode 100644 index 0000000..6efbea5 --- /dev/null +++ b/Assets/Scripts/SerializedObjects/GlobalReferences.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + +namespace Scriptable +{ + [CreateAssetMenu(fileName = "GameState", menuName = "ScriptableObjects/GameStateManager", order = 1)] + public class GlobalReferences : ScriptableObject + { + + } +} diff --git a/Assets/Scripts/SerializedObjects/GlobalReferences.cs.meta b/Assets/Scripts/SerializedObjects/GlobalReferences.cs.meta new file mode 100644 index 0000000..6a4cfa6 --- /dev/null +++ b/Assets/Scripts/SerializedObjects/GlobalReferences.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 18c7601bc264c314faad92cf903c1e46 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Packages/FishNet/Plugins/FishySteamworks/SteamManager.unitypackage.meta b/Assets/VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_HDRP_v1.0.1.unitypackage.meta similarity index 74% rename from Assets/Packages/FishNet/Plugins/FishySteamworks/SteamManager.unitypackage.meta rename to Assets/VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_HDRP_v1.0.1.unitypackage.meta index 7890e6c..a4d019d 100644 --- a/Assets/Packages/FishNet/Plugins/FishySteamworks/SteamManager.unitypackage.meta +++ b/Assets/VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_HDRP_v1.0.1.unitypackage.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a9c34549a246d47439b106bb23f71dff +guid: 96a44475794fb6445a6f3c4b9ee13966 DefaultImporter: externalObjects: {} userData: diff --git a/Assets/VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_URP_v1.0.1.unitypackage.meta b/Assets/VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_URP_v1.0.1.unitypackage.meta new file mode 100644 index 0000000..e4693ea --- /dev/null +++ b/Assets/VFXGraph/GabrielAguiarProductions/VFXGraph_Muzzle_2020.3_URP_v1.0.1.unitypackage.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0957b521a08374f4aa508231735153bc +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: