From 1ac8585934a502e885a710036d0182b1da8f4c79 Mon Sep 17 00:00:00 2001 From: Noah4ever <66632359+Noah4ever@users.noreply.github.com> Date: Mon, 15 Nov 2021 12:59:05 +0100 Subject: [PATCH] Weapon Fix shoot.cs paar sachen --- Assets/Scenes/TestScene.unity | 191 +++++++++++++++++++++++++++++++- Assets/Scripts/Weapons/Shoot.cs | 16 +-- 2 files changed, 190 insertions(+), 17 deletions(-) diff --git a/Assets/Scenes/TestScene.unity b/Assets/Scenes/TestScene.unity index 89bc105..ffb4a8c 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.44657826, g: 0.49641263, b: 0.57481676, a: 1} + m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -123,6 +123,63 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1001 &19517396 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.x + value: 11.294186 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.y + value: 0.407 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.z + value: -0.0155828 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_Name + value: M92 (1) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: bd217f9f85ce78e46a925776562625e8, type: 3} --- !u!1 &39659576 stripped GameObject: m_CorrespondingSourceObject: {fileID: 8009987137999418058, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} @@ -431,6 +488,71 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: -5053925668127403250, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} +--- !u!1001 &342194877 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.x + value: 10.188591 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.y + value: 0.51 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.z + value: 0.06027625 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_Name + value: M92 + objectReference: {fileID: 0} + - target: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_TagString + value: Weapon + objectReference: {fileID: 0} + - target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: weaponKind + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: bd217f9f85ce78e46a925776562625e8, type: 3} --- !u!1001 &419161482 PrefabInstance: m_ObjectHideFlags: 0 @@ -452,7 +574,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3422988367618467043, guid: b62548b3f87093b4dbc561f3dd1abcb8, type: 3} propertyPath: m_RootOrder - value: 5 + value: 6 objectReference: {fileID: 0} - target: {fileID: 3422988367618467043, guid: b62548b3f87093b4dbc561f3dd1abcb8, type: 3} propertyPath: m_LocalPosition.x @@ -799,7 +921,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1001 &739500445 PrefabInstance: @@ -1196,7 +1318,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1351784389 GameObject: @@ -1318,7 +1440,7 @@ RectTransform: - {fileID: 1684293625} - {fileID: 1430445132} m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1619,6 +1741,63 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: -1550514412580984892, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} +--- !u!1001 &1515810369 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.x + value: 11.773485 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.y + value: 0.483 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalPosition.z + value: 1.6332005 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3} + propertyPath: m_Name + value: M92 (2) + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: bd217f9f85ce78e46a925776562625e8, type: 3} --- !u!1 &1683546023 stripped GameObject: m_CorrespondingSourceObject: {fileID: -7146521406498821007, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} @@ -1963,7 +2142,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &8307265127065581321 PrefabInstance: diff --git a/Assets/Scripts/Weapons/Shoot.cs b/Assets/Scripts/Weapons/Shoot.cs index f59c9b5..93a67c5 100644 --- a/Assets/Scripts/Weapons/Shoot.cs +++ b/Assets/Scripts/Weapons/Shoot.cs @@ -48,7 +48,10 @@ public class Shoot : NetworkBehaviour updateCanvas = true; Debug.Log(" click"); CmdFireBullet(); - shootAnim.Recoil(0.1f); + if (weapon.AllowAction) + { + shootAnim.Recoil(0.1f); + } } if (Input.GetButtonDown("Reload")) { updateCanvas = true; @@ -69,35 +72,26 @@ 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 - Debug.Log(" C Ray"); if (Physics.Raycast(ray, out crosshairHitPoint, 5000f)) { // Check if Raycast is beyond 5000 hitpos = crosshairHitPoint.point; // If hitpoint is under 5000 } else { hitpos = mCamera.transform.position + mCamera.transform.forward * 5000; } - Debug.Log("shootAnim.rotationMod"); _pointDirection = hitpos - muzzle.transform.position; _lookRotation = Quaternion.LookRotation(_pointDirection); shootAnim.rotationMod[1] = Quaternion.RotateTowards(weaponHolder.transform.rotation, _lookRotation, 1f); // Point weapon to raycast hitpoint from camera - Debug.Log("Weapon.AllowAction"); + if (weapon.AllowAction) { // If not reloading etc. - Debug.Log("Raycast"); if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit) && weapon.CurrentAmmunition > 0) { // Raycast from Bullet Exit Point to camera raycast - - Debug.DrawLine(muzzle.transform.position, hit.point); - Debug.Log("BulletHole"); bulletHole(GameObject.CreatePrimitive(PrimitiveType.Sphere), hit); // Creates bullethole where raycast hits - Debug.Log("hit Player?"); if (hit.transform.gameObject.GetComponent() != null) { // If hit object is a player Debug.Log("-->HIT PLAYER: " + hit.transform.name); hit.transform.gameObject.GetComponent().RemoveHealth(weapon.Damage); } } - Debug.Log("SubtractAmmunition"); if (limitAmmunition) { subtractAmmunition(weapon); // Subtract Ammunition } - Debug.Log("Firerate"); StartCoroutine(fireRate()); } }