From 1b0d941f07ab1b6673e1317c5481cf9064bff6b2 Mon Sep 17 00:00:00 2001 From: juliuse98 Date: Fri, 12 Nov 2021 11:14:06 +0100 Subject: [PATCH] Merge FIX --- Assets/Objects/Weapons/M9/M92.prefab | 26 ++++- .../Player/Player Animation Test.prefab | 15 ++- Assets/Scenes/TestScene.unity | 4 +- .../Player/ProcedualAnimationController.cs | 2 +- Assets/Scripts/Weapons/Shoot.cs | 30 +++--- .../Layouts/CurrentMaximizeLayout.dwlt | 98 +++++++++---------- 6 files changed, 103 insertions(+), 72 deletions(-) diff --git a/Assets/Objects/Weapons/M9/M92.prefab b/Assets/Objects/Weapons/M9/M92.prefab index eb3f835..76b866f 100644 --- a/Assets/Objects/Weapons/M9/M92.prefab +++ b/Assets/Objects/Weapons/M9/M92.prefab @@ -115,6 +115,7 @@ GameObject: m_Component: - component: {fileID: 732033708985862910} - component: {fileID: 6352645931139448055} + - component: {fileID: 5204381087217674634} m_Layer: 0 m_Name: M92 m_TagString: Untagged @@ -129,7 +130,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 5071598280516985511} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0.03999999} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -153,6 +154,29 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 48948dfe9d76b07488dacd46a7955fa1, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &5204381087217674634 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5071598280516985511} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c98f5c47a8b7dd64f86fd6f42c4d6e5e, type: 3} + m_Name: + m_EditorClassIdentifier: + weaponKind: 0 + active: 0 + damage: 0 + firerate: 320 + roundsPerShot: 1 + recoilStrength: 0 + currentAmmunition: 100 + magazinSize: 100 + totalAmmunition: 100 + bulletExit: {fileID: 2236875552107647873} + allowAction: 1 --- !u!1001 &1330674258901920049 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Player/Player Animation Test.prefab b/Assets/Prefabs/Player/Player Animation Test.prefab index bbe0aaf..0762863 100644 --- a/Assets/Prefabs/Player/Player Animation Test.prefab +++ b/Assets/Prefabs/Player/Player Animation Test.prefab @@ -475,7 +475,7 @@ GameObject: - component: {fileID: 3387435154213398635} - component: {fileID: 5630859218361338035} - component: {fileID: 8436279266335313624} - - component: {fileID: 3781802212159559521} + - component: {fileID: 1258077278480047560} - component: {fileID: 320375778840406984} - component: {fileID: 7273209952621479910} - component: {fileID: 6207632454083444980} @@ -623,6 +623,10 @@ MonoBehaviour: AimPoint: {fileID: 2992488853448454767} HoldPoint: {fileID: 8043317747957554736} isAiming: 0 + rotationMod: + - {x: 0, y: 0, z: 0, w: 0} + - {x: 0, y: 0, z: 0, w: 0} + - {x: 0, y: 0, z: 0, w: 0} --- !u!114 &5630859218361338035 MonoBehaviour: m_ObjectHideFlags: 0 @@ -665,7 +669,7 @@ MonoBehaviour: username: usernameTextObj: {fileID: 0} health: 0 ---- !u!114 &3781802212159559521 +--- !u!114 &1258077278480047560 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -674,15 +678,16 @@ MonoBehaviour: m_GameObject: {fileID: 6272346181302961293} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: bc5bc2b49bd326e4db460a6a3af59311, type: 3} + m_Script: {fileID: 11500000, guid: 0f43c52a1834dcb4bab807bc0cbddec2, type: 3} m_Name: m_EditorClassIdentifier: syncMode: 0 syncInterval: 0.1 muzzle: {fileID: 3649358604728444914} shootAnim: {fileID: 3387435154213398635} - fireRate: 320 - gunHoldPos: {fileID: 3682030003239559187} + weaponHolder: {fileID: 7768205653369755348} + mCamera: {fileID: 6272346181657429395} + limitAmmunition: 1 --- !u!114 &320375778840406984 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/TestScene.unity b/Assets/Scenes/TestScene.unity index b9109e1..89bc105 100644 --- a/Assets/Scenes/TestScene.unity +++ b/Assets/Scenes/TestScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -1233,7 +1233,7 @@ MonoBehaviour: DebugTextGrounded: {fileID: 987854205} DebugTextAmmunition: {fileID: 1430445133} DebugTextClientServer: {fileID: 0} - Player: {fileID: 0} + Player: {fileID: 6272346181302961293, guid: a14d876ac00bdf6498e30b3e58b68fdf, type: 3} GameManager: {fileID: 0} fpsText: {fileID: 72243808} deltaTime: 0 diff --git a/Assets/Scripts/Player/ProcedualAnimationController.cs b/Assets/Scripts/Player/ProcedualAnimationController.cs index 8c625aa..8b17142 100644 --- a/Assets/Scripts/Player/ProcedualAnimationController.cs +++ b/Assets/Scripts/Player/ProcedualAnimationController.cs @@ -91,7 +91,7 @@ public class ProcedualAnimationController : NetworkBehaviour public bool isAiming = false; Vector3[] positionMod = new Vector3[3]; - Quaternion[] rotationMod = new Quaternion[3]; + public Quaternion[] rotationMod = new Quaternion[3]; public void OnSwitchWeapon(float fireRate) diff --git a/Assets/Scripts/Weapons/Shoot.cs b/Assets/Scripts/Weapons/Shoot.cs index 4662329..98953f6 100644 --- a/Assets/Scripts/Weapons/Shoot.cs +++ b/Assets/Scripts/Weapons/Shoot.cs @@ -6,9 +6,8 @@ using TMPro; public class Shoot : NetworkBehaviour { [SerializeField] GameObject muzzle; - [SerializeField] ShootAnimation shootAnim; + [SerializeField] ProcedualAnimationController shootAnim; [SerializeField] GameObject weaponHolder; - [SerializeField] GameObject GunRotation; [SerializeField] Camera mCamera; [SerializeField] bool limitAmmunition = true; @@ -26,7 +25,10 @@ public class Shoot : NetworkBehaviour public int TotalAmmo { get => totalAmmo; set => totalAmmo = value; } private void Start() { - + if (isServer) { + weapon = weaponHolder.GetComponent(); + shootAnim.OnSwitchWeapon(weapon.Firerate); + } if (isLocalPlayer) { weapon = weaponHolder.GetComponent(); shootAnim.OnSwitchWeapon(weapon.Firerate); @@ -44,7 +46,9 @@ public class Shoot : NetworkBehaviour } if (Input.GetButtonDown("Fire")) { updateCanvas = true; + Debug.Log(" click"); CmdFireBullet(); + shootAnim.Recoil(0.1f); } if (Input.GetButtonDown("Reload")) { updateCanvas = true; @@ -65,18 +69,21 @@ public class Shoot : NetworkBehaviour // This code will be executed on the Server. private void CmdFireBullet() { ray = new Ray(mCamera.transform.position, mCamera.transform.forward); // Raycast from Camera - if(Physics.Raycast(ray, out crosshairHitPoint, 5000f)) { // Check if Raycast is beyond 5000 + Debug.Log(" C Ray"); + if (Physics.Raycast(ray, out crosshairHitPoint, 5000f)) { // Check if Raycast is beyond 5000 + Debug.Log(" floor"); hitpos = crosshairHitPoint.point; // If hitpoint is under 5000 - } else { + } else { hitpos = mCamera.transform.position + mCamera.transform.forward * 5000; } + _pointDirection = hitpos - muzzle.transform.position; _lookRotation = Quaternion.LookRotation(_pointDirection); - GunRotation.transform.rotation = Quaternion.RotateTowards(GunRotation.transform.rotation, _lookRotation, 1f); // Point weapon to raycast hitpoint from camera - + shootAnim.rotationMod[1] = Quaternion.RotateTowards(weaponHolder.transform.rotation, _lookRotation, 1f); // Point weapon to raycast hitpoint from camera + if (weapon.AllowAction) { // If not reloading etc. if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit) && weapon.CurrentAmmunition > 0) { // Raycast from Bullet Exit Point to camera raycast - shootAnimation(); // Start Shoot Animation + Debug.DrawLine(muzzle.transform.position, hit.point); bulletHole(GameObject.CreatePrimitive(PrimitiveType.Sphere), hit); // Creates bullethole where raycast hits @@ -90,7 +97,7 @@ public class Shoot : NetworkBehaviour subtractAmmunition(weapon); // Subtract Ammunition } StartCoroutine(fireRate()); - } + } } void bulletHole(GameObject holeObject, RaycastHit hit) @@ -99,11 +106,6 @@ public class Shoot : NetworkBehaviour holeObject.transform.position = hit.point; } - [Client] - void shootAnimation() { - shootAnim.recoil(0.1f); - } - IEnumerator fireRate() { weapon.AllowAction = false; diff --git a/UserSettings/Layouts/CurrentMaximizeLayout.dwlt b/UserSettings/Layouts/CurrentMaximizeLayout.dwlt index 485fcc8..a1d1e0c 100644 --- a/UserSettings/Layouts/CurrentMaximizeLayout.dwlt +++ b/UserSettings/Layouts/CurrentMaximizeLayout.dwlt @@ -45,10 +45,10 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 711.2 + x: 709.60004 y: 73.6 - width: 457.99994 - height: 451 + width: 459.59998 + height: 451.8 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -59,7 +59,7 @@ MonoBehaviour: m_ShowGizmos: 0 m_TargetDisplay: 0 m_ClearColor: {r: 0, g: 0, b: 0, a: 0} - m_TargetSize: {x: 457.99994, y: 430} + m_TargetSize: {x: 459.59998, y: 430.8} m_TextureFilterMode: 0 m_TextureHideFlags: 61 m_RenderIMGUI: 1 @@ -74,10 +74,10 @@ MonoBehaviour: m_VRangeLocked: 0 hZoomLockedByDefault: 0 vZoomLockedByDefault: 0 - m_HBaseRangeMin: -183.19998 - m_HBaseRangeMax: 183.19998 - m_VBaseRangeMin: -172 - m_VBaseRangeMax: 172 + m_HBaseRangeMin: -183.84 + m_HBaseRangeMax: 183.84 + m_VBaseRangeMin: -172.31999 + m_VBaseRangeMax: 172.31999 m_HAllowExceedBaseRangeMin: 1 m_HAllowExceedBaseRangeMax: 1 m_VAllowExceedBaseRangeMin: 1 @@ -95,23 +95,23 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 21 - width: 457.99994 - height: 430 + width: 459.59998 + height: 430.8 m_Scale: {x: 1, y: 1} - m_Translation: {x: 228.99997, y: 215} + m_Translation: {x: 229.79999, y: 215.4} m_MarginLeft: 0 m_MarginRight: 0 m_MarginTop: 0 m_MarginBottom: 0 m_LastShownAreaInsideMargins: serializedVersion: 2 - x: -228.99997 - y: -215 - width: 457.99994 - height: 430 + x: -229.79999 + y: -215.4 + width: 459.59998 + height: 430.8 m_MinimalGUI: 1 m_defaultScale: 1 - m_LastWindowPixelSize: {x: 572.49994, y: 563.75} + m_LastWindowPixelSize: {x: 574.5, y: 564.75} m_ClearInEditMode: 1 m_NoCameraWarning: 1 m_LowResolutionForAspectRatios: 01000000000000000000 @@ -163,7 +163,7 @@ MonoBehaviour: x: 0 y: 0 width: 1171.2 - height: 472 + height: 472.8 m_MinSize: {x: 300, y: 100} m_MaxSize: {x: 24288, y: 8096} vertical: 0 @@ -185,10 +185,10 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 296 - height: 472 - m_MinSize: {x: 201, y: 221} - m_MaxSize: {x: 4001, y: 4021} + width: 293.6 + height: 472.8 + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 6} m_Panes: - {fileID: 6} @@ -216,8 +216,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 73.6 - width: 295 - height: 451 + width: 292.6 + height: 451.8 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -227,7 +227,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 2afbffff + m_ExpandedIDs: deecfeff30edfeff98effeff20fafeff72fafeffdafcfeff4c06ffffa606ffff0e09ffff6613ffffb813ffff2016ffffd81effff2a1fffff9221ffff442effff962efffffe30ffff7038ffffc238ffff2a3bffff3441ffff8841fffff043ffffc258ffff1459ffff7c5bffff6a62ffffc462ffff2c65ffffd86fffff2a70ffff9272ffff6680ffffb880ffff2083ffff408affff928afffffa8cffffb893ffff0a94ffff7296ffff3499ffff8699ffffee9bffff269effff789effffe0a0ffffa2abffffaaabffffb0abffffdcabffff50eeffff2afbffff m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -266,10 +266,10 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 296 + x: 293.6 y: 0 - width: 415.2 - height: 472 + width: 415.99997 + height: 472.8 m_MinSize: {x: 200, y: 200} m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 9} @@ -362,10 +362,10 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 296 + x: 293.6 y: 73.6 - width: 413.2 - height: 451 + width: 413.99997 + height: 451.8 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -430,9 +430,9 @@ MonoBehaviour: floating: 0 collapsed: 0 displayed: 1 - snapOffset: {x: 67.5, y: 86} + snapOffset: {x: -171.7, y: 86} snapOffsetDelta: {x: 0, y: 0} - snapCorner: 0 + snapCorner: 1 id: Orientation index: 0 layout: 4 @@ -673,10 +673,10 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 711.2 + x: 709.6 y: 0 - width: 459.99994 - height: 472 + width: 461.59998 + height: 472.8 m_MinSize: {x: 200, y: 200} m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 2} @@ -700,9 +700,9 @@ MonoBehaviour: m_Position: serializedVersion: 2 x: 0 - y: 472 + y: 472.8 width: 1171.2 - height: 258.8 + height: 258 m_MinSize: {x: 100, y: 100} m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 13} @@ -731,10 +731,10 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1536 - y: 684 - width: 1463 - height: 315 + x: 0 + y: 546.4 + width: 1170.2 + height: 237 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -752,22 +752,22 @@ MonoBehaviour: m_SkipHidden: 0 m_SearchArea: 1 m_Folders: - - Assets/Scenes + - Assets/Prefabs/Player m_Globs: [] m_OriginalText: m_ViewMode: 1 m_StartGridSize: 64 m_LastFolders: - - Assets/Scenes + - Assets/Prefabs/Player m_LastFoldersGridSize: -1 m_LastProjectPath: C:\Users\juliu\Desktop\Ausbildung\Fps-build\3d-shooter m_LockTracker: m_IsLocked: 0 m_FolderTreeState: - scrollPos: {x: 0, y: 120} - m_SelectedIDs: d8640000 - m_LastClickedID: 25816 - m_ExpandedIDs: 000000000a6300000c6300000e630000 + scrollPos: {x: 0, y: 167} + m_SelectedIDs: 16650000 + m_LastClickedID: 25878 + m_ExpandedIDs: 000000000a6300000c6300000e630000dc640000e064000000ca9a3bffffff7f m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -872,9 +872,9 @@ MonoBehaviour: m_Pos: serializedVersion: 2 x: 0 - y: 545.60004 + y: 546.4 width: 1170.2 - height: 237.79999 + height: 237 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default