mirror of
				https://github.com/DerTyp7/defrain-shooter-unity.git
				synced 2025-10-29 20:52:10 +01:00 
			
		
		
		
	Weapon Switching/pickup/throw
[+] added + added pickup weapons + added throw weapons + added weapon switching + scrolling searches for next active weapon [n] needs to be added n weapon in correct position after pickup n after weapon throw -> next active weapon needs to be equipt n throw/pickup/switch weapon animation
This commit is contained in:
		| @@ -169,7 +169,7 @@ Transform: | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 7014992348987952529} | ||||
|   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||||
|   m_LocalPosition: {x: 0.0594, y: 0.123, z: 0} | ||||
|   m_LocalPosition: {x: -0.003, y: 0.04, z: 0.161} | ||||
|   m_LocalScale: {x: 1, y: 1, z: 1} | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 8797726366404580855} | ||||
| @@ -212,7 +212,7 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: -8679921383154817045, guid: db8a9548ba56c1949bb28f7c6129bbeb, type: 3} | ||||
|       propertyPath: m_LocalPosition.z | ||||
|       value: 0 | ||||
|       value: 0.137 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: -8679921383154817045, guid: db8a9548ba56c1949bb28f7c6129bbeb, type: 3} | ||||
|       propertyPath: m_LocalRotation.w | ||||
|   | ||||
| @@ -48,7 +48,7 @@ MonoBehaviour: | ||||
|     m_Root: {fileID: 8334588817950881727} | ||||
|     m_Mid: {fileID: 5739201115059209923} | ||||
|     m_Tip: {fileID: 1706812538552309319} | ||||
|     m_Target: {fileID: 2781132594439880980} | ||||
|     m_Target: {fileID: 2065766509905691831} | ||||
|     m_Hint: {fileID: 0} | ||||
|     m_TargetPositionWeight: 1 | ||||
|     m_TargetRotationWeight: 1 | ||||
| @@ -103,7 +103,7 @@ MonoBehaviour: | ||||
|     m_Root: {fileID: 9127245645273413481} | ||||
|     m_Mid: {fileID: 8862008152122197222} | ||||
|     m_Tip: {fileID: 8703533484509679896} | ||||
|     m_Target: {fileID: 9064841067161443684} | ||||
|     m_Target: {fileID: 909324728237481282} | ||||
|     m_Hint: {fileID: 0} | ||||
|     m_TargetPositionWeight: 1 | ||||
|     m_TargetRotationWeight: 1 | ||||
| @@ -606,8 +606,8 @@ MonoBehaviour: | ||||
|   playerController: {fileID: -4574526707603160507} | ||||
|   currentCameraRecoilX: 0 | ||||
|   currentCameraRecoilY: 0 | ||||
|   gun: {fileID: 3682030003239559187} | ||||
|   gunHolder: {fileID: 7768205653369755348} | ||||
|   gun: {fileID: 3995507965915027724} | ||||
|   gunHolder: {fileID: 8280541971482439080} | ||||
|   positionRecoil: 1 | ||||
|   rotationRecoil: 1 | ||||
|   positionMultX: 2 | ||||
| @@ -836,7 +836,7 @@ MonoBehaviour: | ||||
|   showGizmos: 0 | ||||
|   showOverlay: 0 | ||||
|   overlayColor: {r: 0, g: 0, b: 0, a: 0.5} | ||||
|   target: {fileID: 2848367205963120269} | ||||
|   target: {fileID: 1363144486119695814} | ||||
| --- !u!95 &8957579265169979397 | ||||
| Animator: | ||||
|   serializedVersion: 3 | ||||
| @@ -888,6 +888,7 @@ MonoBehaviour: | ||||
|   syncInterval: 0.1 | ||||
|   currentWeaponIndex: 0 | ||||
|   activeWeapons: [] | ||||
|   gunHolster: {fileID: 6522444664664986769} | ||||
|   cam: {fileID: 6272346181657429395} | ||||
| --- !u!1 &6272346181657429393 | ||||
| GameObject: | ||||
| @@ -1233,26 +1234,11 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     m_RemovedComponents: [] | ||||
|   m_SourcePrefab: {fileID: 100100000, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
| --- !u!1 &3682030003239559187 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 2213212323547960416, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
|   m_PrefabInstance: {fileID: 3292089710699836531} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!1 &3649358604728444914 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 2236875552107647873, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
|   m_PrefabInstance: {fileID: 3292089710699836531} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!4 &2781132594439880980 stripped | ||||
| Transform: | ||||
|   m_CorrespondingSourceObject: {fileID: 808197646603973991, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
|   m_PrefabInstance: {fileID: 3292089710699836531} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!4 &9064841067161443684 stripped | ||||
| Transform: | ||||
|   m_CorrespondingSourceObject: {fileID: 5792494204646893847, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
|   m_PrefabInstance: {fileID: 3292089710699836531} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!1 &7768205653369755348 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
| @@ -1469,11 +1455,23 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 1880099159927430553, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_IsActive | ||||
|       value: 0 | ||||
|       value: 1 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 5139256649524637864, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.x | ||||
|       value: -0.008 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 5139256649524637864, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.y | ||||
|       value: 0.055 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 5139256649524637864, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.z | ||||
|       value: 0.167 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.x | ||||
|       value: 0.0324 | ||||
|       value: 0.034 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.y | ||||
| @@ -1483,9 +1481,33 @@ PrefabInstance: | ||||
|       propertyPath: m_LocalPosition.z | ||||
|       value: -0.2867 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.w | ||||
|       value: 0 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.x | ||||
|       value: 0 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.y | ||||
|       value: 0.7071068 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.z | ||||
|       value: 0.7071068 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalEulerAnglesHint.x | ||||
|       value: -90 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalEulerAnglesHint.y | ||||
|       value: 180 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.x | ||||
|       value: -0.03000002 | ||||
|       value: -0.039 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.y | ||||
| @@ -1495,6 +1517,30 @@ PrefabInstance: | ||||
|       propertyPath: m_LocalPosition.z | ||||
|       value: -0.2881 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.w | ||||
|       value: 0 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.x | ||||
|       value: 0 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.y | ||||
|       value: 0.7071068 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.z | ||||
|       value: 0.7071068 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalEulerAnglesHint.x | ||||
|       value: -90 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalEulerAnglesHint.y | ||||
|       value: 180 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_RootOrder | ||||
|       value: 2 | ||||
| @@ -1541,6 +1587,11 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     m_RemovedComponents: [] | ||||
|   m_SourcePrefab: {fileID: 100100000, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
| --- !u!1 &8280541971482439080 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 1880099159927430553, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|   m_PrefabInstance: {fileID: 7565221866438160433} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!4 &1363144486119695814 stripped | ||||
| Transform: | ||||
|   m_CorrespondingSourceObject: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
| @@ -1551,3 +1602,13 @@ GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 6885991082275612989, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|   m_PrefabInstance: {fileID: 7565221866438160433} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!4 &2065766509905691831 stripped | ||||
| Transform: | ||||
|   m_CorrespondingSourceObject: {fileID: 8382890533894468742, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|   m_PrefabInstance: {fileID: 7565221866438160433} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!4 &909324728237481282 stripped | ||||
| Transform: | ||||
|   m_CorrespondingSourceObject: {fileID: 7233769674171919731, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|   m_PrefabInstance: {fileID: 7565221866438160433} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   | ||||
| @@ -38,7 +38,7 @@ RenderSettings: | ||||
|   m_ReflectionIntensity: 1 | ||||
|   m_CustomReflection: {fileID: 0} | ||||
|   m_Sun: {fileID: 705507994} | ||||
|   m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1} | ||||
|   m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} | ||||
|   m_UseRadianceAmbientProbe: 0 | ||||
| --- !u!157 &3 | ||||
| LightmapSettings: | ||||
| @@ -258,7 +258,7 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 4636852677861728911, guid: e4f2c82228df5bc4f8fc674e98c7275b, type: 3} | ||||
|       propertyPath: m_IsActive | ||||
|       value: 0 | ||||
|       value: 1 | ||||
|       objectReference: {fileID: 0} | ||||
|     m_RemovedComponents: [] | ||||
|   m_SourcePrefab: {fileID: 100100000, guid: e4f2c82228df5bc4f8fc674e98c7275b, type: 3} | ||||
| @@ -457,7 +457,7 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
|       propertyPath: weaponKind | ||||
|       value: 1 | ||||
|       value: 0 | ||||
|       objectReference: {fileID: 0} | ||||
|     m_RemovedComponents: [] | ||||
|   m_SourcePrefab: {fileID: 100100000, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
| @@ -478,11 +478,11 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.x | ||||
|       value: 10.129 | ||||
|       value: 10.12892 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.y | ||||
|       value: 0.303 | ||||
|       value: 0.30300653 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalPosition.z | ||||
| @@ -490,19 +490,19 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.w | ||||
|       value: 1 | ||||
|       value: 0.9999914 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.x | ||||
|       value: 0 | ||||
|       value: -0 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.y | ||||
|       value: 0 | ||||
|       value: -0 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalRotation.z | ||||
|       value: 0 | ||||
|       value: 0.0041435333 | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalEulerAnglesHint.x | ||||
| @@ -514,7 +514,7 @@ PrefabInstance: | ||||
|       objectReference: {fileID: 0} | ||||
|     - target: {fileID: 8797726366404580855, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|       propertyPath: m_LocalEulerAnglesHint.z | ||||
|       value: 0 | ||||
|       value: 0.475 | ||||
|       objectReference: {fileID: 0} | ||||
|     m_RemovedComponents: [] | ||||
|   m_SourcePrefab: {fileID: 100100000, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
| @@ -1037,6 +1037,27 @@ MeshCollider: | ||||
|   m_Convex: 0 | ||||
|   m_CookingOptions: 30 | ||||
|   m_Mesh: {fileID: -1550514412580984892, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} | ||||
| --- !u!1 &1657029747 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3} | ||||
|   m_PrefabInstance: {fileID: 342194877} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!54 &1657029752 | ||||
| Rigidbody: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 1657029747} | ||||
|   serializedVersion: 2 | ||||
|   m_Mass: 1 | ||||
|   m_Drag: 0 | ||||
|   m_AngularDrag: 0.05 | ||||
|   m_UseGravity: 1 | ||||
|   m_IsKinematic: 0 | ||||
|   m_Interpolate: 0 | ||||
|   m_Constraints: 0 | ||||
|   m_CollisionDetection: 0 | ||||
| --- !u!1 &1683546023 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: -7146521406498821007, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} | ||||
| @@ -1056,6 +1077,27 @@ MeshCollider: | ||||
|   m_Convex: 0 | ||||
|   m_CookingOptions: 30 | ||||
|   m_Mesh: {fileID: -8678823145569952518, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} | ||||
| --- !u!1 &1721250000 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 1880099159927430553, guid: 6f5ccb6e55f1676429c170257dc7a411, type: 3} | ||||
|   m_PrefabInstance: {fileID: 409053569} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
| --- !u!54 &1721250005 | ||||
| Rigidbody: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 1721250000} | ||||
|   serializedVersion: 2 | ||||
|   m_Mass: 1 | ||||
|   m_Drag: 0 | ||||
|   m_AngularDrag: 0.05 | ||||
|   m_UseGravity: 1 | ||||
|   m_IsKinematic: 0 | ||||
|   m_Interpolate: 0 | ||||
|   m_Constraints: 0 | ||||
|   m_CollisionDetection: 0 | ||||
| --- !u!1 &1767188876 stripped | ||||
| GameObject: | ||||
|   m_CorrespondingSourceObject: {fileID: 281855664364225751, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3} | ||||
|   | ||||
| @@ -44,7 +44,7 @@ public class Shoot : NetworkBehaviour | ||||
|                 totalAmmo = weapon.TotalAmmunition; | ||||
|                 updateCanvas = false; | ||||
|             } | ||||
|             if (Input.GetButtonDown("Fire")) { | ||||
|             if (Input.GetButtonDown("Fire")) { // BOX COLLIDER AUS | ||||
|                 updateCanvas = true; | ||||
|                 Debug.Log(" click"); | ||||
|                 if (weapon.AllowAction && weapon.CurrentAmmunition > 0) | ||||
|   | ||||
| @@ -7,64 +7,91 @@ using Mirror; | ||||
| public class WeaponManager : NetworkBehaviour | ||||
| { | ||||
|     public int currentWeaponIndex = 0; | ||||
|     public GameObject[] activeWeapons; | ||||
|     private int lastWeaponIndex = 0; | ||||
|     private int counter = 0; | ||||
|     public List<GameObject> activeWeapons = new List<GameObject>(); | ||||
|  | ||||
|  | ||||
|     [SerializeField] GameObject gunHolster; | ||||
|     [SerializeField] Camera cam; | ||||
|  | ||||
|     private void Awake() | ||||
|     { | ||||
|         activeWeapons = new GameObject[4]; | ||||
|         for(int i = 0; i<4; i++) | ||||
|         { | ||||
|             activeWeapons[i] = null; | ||||
|             activeWeapons.Add(null); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     void Update() { | ||||
|         if (isLocalPlayer) { | ||||
|             counter = 0; | ||||
|             if(Input.GetAxis("Mouse ScrollWheel") > 0f){ // Scroll up | ||||
|                 do | ||||
|                 { | ||||
|                     if (currentWeaponIndex <= 0) | ||||
|                     { | ||||
|                         currentWeaponIndex = activeWeapons.Length - 1; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                 lastWeaponIndex = currentWeaponIndex; | ||||
|                 counter = 0; | ||||
|                 do { | ||||
|                     if (currentWeaponIndex <= 0) { | ||||
|                         currentWeaponIndex = activeWeapons.Count - 1; | ||||
|                     } else { | ||||
|                         currentWeaponIndex--; | ||||
|                     } | ||||
|                     counter++; | ||||
|                     //Debug.Log(activeWeapons[currentWeaponIndex]); | ||||
|                     if (counter > 10) { break; } | ||||
|                 } while (activeWeapons[currentWeaponIndex] == null); | ||||
|                 if (lastWeaponIndex != currentWeaponIndex && activeWeapons[currentWeaponIndex] != null) | ||||
|                 { | ||||
|                     // play switch animation or move weapon (hands) down | ||||
|                     foreach (GameObject obj in activeWeapons) | ||||
|                     { // Disable all weapons | ||||
|                         if (obj != null) { obj.SetActive(false); } | ||||
|                     } | ||||
|                     Debug.Log("Set Active (" + currentWeaponIndex + "): " + activeWeapons[currentWeaponIndex].name); | ||||
|                     activeWeapons[currentWeaponIndex].SetActive(true); | ||||
|                 } | ||||
|             } | ||||
|             else if (Input.GetAxis("Mouse ScrollWheel") < 0f){ // Scroll down | ||||
|                 do | ||||
|                 { | ||||
|                     if (currentWeaponIndex >= activeWeapons.Length - 1) | ||||
|                     { | ||||
|                 lastWeaponIndex = currentWeaponIndex; | ||||
|                 counter = 0; | ||||
|                 do { | ||||
|                     if (currentWeaponIndex >= activeWeapons.Count - 1) { | ||||
|                         currentWeaponIndex = 0; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                     } else { | ||||
|                         currentWeaponIndex++; | ||||
|                     } | ||||
|                     counter++; | ||||
|                     //Debug.Log(activeWeapons[currentWeaponIndex]); | ||||
|                     if(counter > 10) { break; } | ||||
|                 } while (activeWeapons[currentWeaponIndex] == null); | ||||
|                  | ||||
|                 if (lastWeaponIndex != currentWeaponIndex && activeWeapons[currentWeaponIndex] != null) | ||||
|                 { | ||||
|                     // play switch animation or move weapon (hands) down | ||||
|                     foreach (GameObject obj in activeWeapons) | ||||
|                     { // Disable all weapons | ||||
|                         if (obj != null) { obj.SetActive(false); } | ||||
|                     } | ||||
|                     Debug.Log("Set Active (" + currentWeaponIndex + "): " + activeWeapons[currentWeaponIndex].name); | ||||
|                     activeWeapons[currentWeaponIndex].SetActive(true); | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|             if (Input.GetButton("Interact")) // e | ||||
|             if (Input.GetButtonDown("Interact")) // e | ||||
|             { | ||||
|                 CmdPickupWeapon(); | ||||
|              | ||||
|             }else if (Input.GetButton("Drop")) // q Droping weapon | ||||
|             }else if (Input.GetButtonDown("Drop")) // q Droping weapon | ||||
|             { | ||||
|                 activeWeapons[currentWeaponIndex] = null; | ||||
|                 // WENN GEDROPT WIRD MUSS DIE N<>CHSTE AKTIVE GSUCHT WERDEn | ||||
|                 if(activeWeapons[currentWeaponIndex] != null) | ||||
|                 { | ||||
|                     activeWeapons[currentWeaponIndex].GetComponent<Rigidbody>().useGravity = true; | ||||
|                     activeWeapons[currentWeaponIndex].GetComponent<Rigidbody>().isKinematic = false; | ||||
|                     activeWeapons[currentWeaponIndex].transform.position = cam.transform.position; | ||||
|                     activeWeapons[currentWeaponIndex].GetComponent<BoxCollider>().enabled = true; | ||||
|                     activeWeapons[currentWeaponIndex].GetComponent<Rigidbody>().velocity = cam.transform.forward * 10 + cam.transform.up * 2; | ||||
|                     activeWeapons[currentWeaponIndex].gameObject.transform.SetParent(null); | ||||
|                     activeWeapons[currentWeaponIndex] = null; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     [Command] | ||||
| @@ -73,8 +100,16 @@ public class WeaponManager : NetworkBehaviour | ||||
|         { | ||||
|             if (hit.transform.tag == "Weapon") // If Object is a weapon and the weapon is not in the current active weapons | ||||
|             { | ||||
|                  | ||||
|                 foreach (GameObject obj in activeWeapons) { // Disable all weapons | ||||
|                     if (obj != null) { obj.SetActive(false); } | ||||
|                 } | ||||
|                 hit.transform.parent = gunHolster.transform; // Parent weapon to gunHolster | ||||
|                 hit.rigidbody.isKinematic = true; | ||||
|                 hit.rigidbody.useGravity = false; | ||||
|                 hit.transform.GetComponent<BoxCollider>().enabled = false; // Disable Boxcollider  | ||||
|                 hit.transform.position = cam.transform.position; | ||||
|                 switch (hit.transform.GetComponent<Weapon>().WeaponKind.ToString()) // Adding weapon to inventory slot | ||||
|  | ||||
|                 { | ||||
|                     case "Rifle": activeWeapons[0] = hit.transform.gameObject; break; | ||||
|                     case "Pistole": activeWeapons[1] = hit.transform.gameObject; break; | ||||
|   | ||||
| @@ -19,7 +19,7 @@ MonoBehaviour: | ||||
|     width: 1536 | ||||
|     height: 780.8 | ||||
|   m_ShowMode: 4 | ||||
|   m_Title: Project | ||||
|   m_Title: Inspector | ||||
|   m_RootView: {fileID: 2} | ||||
|   m_MinSize: {x: 875, y: 300} | ||||
|   m_MaxSize: {x: 10000, y: 10000} | ||||
| @@ -119,7 +119,7 @@ MonoBehaviour: | ||||
|   m_MinSize: {x: 400, y: 200} | ||||
|   m_MaxSize: {x: 32384, y: 16192} | ||||
|   vertical: 0 | ||||
|   controlID: 111 | ||||
|   controlID: 105 | ||||
| --- !u!114 &6 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 52 | ||||
| @@ -144,7 +144,7 @@ MonoBehaviour: | ||||
|   m_MinSize: {x: 300, y: 200} | ||||
|   m_MaxSize: {x: 24288, y: 16192} | ||||
|   vertical: 1 | ||||
|   controlID: 112 | ||||
|   controlID: 120 | ||||
| --- !u!114 &7 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 52 | ||||
| @@ -166,11 +166,11 @@ MonoBehaviour: | ||||
|     x: 0 | ||||
|     y: 0 | ||||
|     width: 1269 | ||||
|     height: 439 | ||||
|     height: 439.2 | ||||
|   m_MinSize: {x: 300, y: 100} | ||||
|   m_MaxSize: {x: 24288, y: 8096} | ||||
|   vertical: 0 | ||||
|   controlID: 113 | ||||
|   controlID: 121 | ||||
| --- !u!114 &8 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 52 | ||||
| @@ -188,8 +188,8 @@ MonoBehaviour: | ||||
|     serializedVersion: 2 | ||||
|     x: 0 | ||||
|     y: 0 | ||||
|     width: 243 | ||||
|     height: 439 | ||||
|     width: 243.2 | ||||
|     height: 439.2 | ||||
|   m_MinSize: {x: 201, y: 221} | ||||
|   m_MaxSize: {x: 4001, y: 4021} | ||||
|   m_ActualView: {fileID: 14} | ||||
| @@ -212,10 +212,10 @@ MonoBehaviour: | ||||
|   m_Children: [] | ||||
|   m_Position: | ||||
|     serializedVersion: 2 | ||||
|     x: 243 | ||||
|     x: 243.2 | ||||
|     y: 0 | ||||
|     width: 493 | ||||
|     height: 439 | ||||
|     width: 492.8 | ||||
|     height: 439.2 | ||||
|   m_MinSize: {x: 202, y: 221} | ||||
|   m_MaxSize: {x: 4002, y: 4021} | ||||
|   m_ActualView: {fileID: 16} | ||||
| @@ -242,9 +242,9 @@ MonoBehaviour: | ||||
|     x: 736 | ||||
|     y: 0 | ||||
|     width: 533 | ||||
|     height: 439 | ||||
|   m_MinSize: {x: 200, y: 200} | ||||
|   m_MaxSize: {x: 4000, y: 4000} | ||||
|     height: 439.2 | ||||
|   m_MinSize: {x: 202, y: 221} | ||||
|   m_MaxSize: {x: 4002, y: 4021} | ||||
|   m_ActualView: {fileID: 13} | ||||
|   m_Panes: | ||||
|   - {fileID: 13} | ||||
| @@ -260,23 +260,23 @@ MonoBehaviour: | ||||
|   m_Enabled: 1 | ||||
|   m_EditorHideFlags: 1 | ||||
|   m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0} | ||||
|   m_Name: ProjectBrowser | ||||
|   m_Name: ConsoleWindow | ||||
|   m_EditorClassIdentifier:  | ||||
|   m_Children: [] | ||||
|   m_Position: | ||||
|     serializedVersion: 2 | ||||
|     x: 0 | ||||
|     y: 439 | ||||
|     y: 439.2 | ||||
|     width: 1269 | ||||
|     height: 292 | ||||
|   m_MinSize: {x: 231, y: 271} | ||||
|   m_MaxSize: {x: 10001, y: 10021} | ||||
|   m_ActualView: {fileID: 17} | ||||
|     height: 291.8 | ||||
|   m_MinSize: {x: 101, y: 121} | ||||
|   m_MaxSize: {x: 4001, y: 4021} | ||||
|   m_ActualView: {fileID: 18} | ||||
|   m_Panes: | ||||
|   - {fileID: 17} | ||||
|   - {fileID: 18} | ||||
|   m_Selected: 0 | ||||
|   m_LastSelected: 1 | ||||
|   m_Selected: 1 | ||||
|   m_LastSelected: 0 | ||||
| --- !u!114 &12 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 52 | ||||
| @@ -326,7 +326,7 @@ MonoBehaviour: | ||||
|     x: 736 | ||||
|     y: 73.6 | ||||
|     width: 531 | ||||
|     height: 418 | ||||
|     height: 418.2 | ||||
|   m_ViewDataDictionary: {fileID: 0} | ||||
|   m_OverlayCanvas: | ||||
|     m_LastAppliedPresetName: Default | ||||
| @@ -337,7 +337,7 @@ MonoBehaviour: | ||||
|   m_ShowGizmos: 0 | ||||
|   m_TargetDisplay: 0 | ||||
|   m_ClearColor: {r: 0, g: 0, b: 0, a: 0} | ||||
|   m_TargetSize: {x: 531, y: 397} | ||||
|   m_TargetSize: {x: 531, y: 397.2} | ||||
|   m_TextureFilterMode: 0 | ||||
|   m_TextureHideFlags: 61 | ||||
|   m_RenderIMGUI: 1 | ||||
| @@ -354,15 +354,15 @@ MonoBehaviour: | ||||
|     vZoomLockedByDefault: 0 | ||||
|     m_HBaseRangeMin: -212.40001 | ||||
|     m_HBaseRangeMax: 212.40001 | ||||
|     m_VBaseRangeMin: -158.8 | ||||
|     m_VBaseRangeMax: 158.8 | ||||
|     m_VBaseRangeMin: -158.88 | ||||
|     m_VBaseRangeMax: 158.88 | ||||
|     m_HAllowExceedBaseRangeMin: 1 | ||||
|     m_HAllowExceedBaseRangeMax: 1 | ||||
|     m_VAllowExceedBaseRangeMin: 1 | ||||
|     m_VAllowExceedBaseRangeMax: 1 | ||||
|     m_ScaleWithWindow: 0 | ||||
|     m_HSlider: 1 | ||||
|     m_VSlider: 1 | ||||
|     m_HSlider: 0 | ||||
|     m_VSlider: 0 | ||||
|     m_IgnoreScrollWheelUntilClicked: 0 | ||||
|     m_EnableMouseInput: 1 | ||||
|     m_EnableSliderZoomHorizontal: 0 | ||||
| @@ -374,22 +374,22 @@ MonoBehaviour: | ||||
|       x: 0 | ||||
|       y: 21 | ||||
|       width: 531 | ||||
|       height: 397 | ||||
|     m_Scale: {x: 1.2742728, y: 1.2742728} | ||||
|     m_Translation: {x: 260.34442, y: 200.231} | ||||
|       height: 397.2 | ||||
|     m_Scale: {x: 1.2349323, y: 1.2349323} | ||||
|     m_Translation: {x: 265.5, y: 198.6} | ||||
|     m_MarginLeft: 0 | ||||
|     m_MarginRight: 0 | ||||
|     m_MarginTop: 0 | ||||
|     m_MarginBottom: 0 | ||||
|     m_LastShownAreaInsideMargins: | ||||
|       serializedVersion: 2 | ||||
|       x: -204.30823 | ||||
|       y: -157.13354 | ||||
|       width: 416.70825 | ||||
|       height: 311.55023 | ||||
|       x: -214.99155 | ||||
|       y: -160.81854 | ||||
|       width: 429.9831 | ||||
|       height: 321.6371 | ||||
|     m_MinimalGUI: 1 | ||||
|   m_defaultScale: 1 | ||||
|   m_LastWindowPixelSize: {x: 663.75, y: 522.5} | ||||
|   m_LastWindowPixelSize: {x: 663.75, y: 522.75} | ||||
|   m_ClearInEditMode: 1 | ||||
|   m_NoCameraWarning: 1 | ||||
|   m_LowResolutionForAspectRatios: 01000000000000000000 | ||||
| @@ -417,8 +417,8 @@ MonoBehaviour: | ||||
|     serializedVersion: 2 | ||||
|     x: 0 | ||||
|     y: 73.6 | ||||
|     width: 242 | ||||
|     height: 418 | ||||
|     width: 242.2 | ||||
|     height: 418.2 | ||||
|   m_ViewDataDictionary: {fileID: 0} | ||||
|   m_OverlayCanvas: | ||||
|     m_LastAppliedPresetName: Default | ||||
| @@ -426,9 +426,9 @@ MonoBehaviour: | ||||
|   m_SceneHierarchy: | ||||
|     m_TreeViewState: | ||||
|       scrollPos: {x: 0, y: 0} | ||||
|       m_SelectedIDs:  | ||||
|       m_LastClickedID: 0 | ||||
|       m_ExpandedIDs: 2afbffff | ||||
|       m_SelectedIDs: eabaffff | ||||
|       m_LastClickedID: -17686 | ||||
|       m_ExpandedIDs: 72bdffff28fbffff | ||||
|       m_RenameOverlay: | ||||
|         m_UserAcceptedRename: 0 | ||||
|         m_Name:  | ||||
| @@ -538,8 +538,8 @@ MonoBehaviour: | ||||
|     serializedVersion: 2 | ||||
|     x: 243.2 | ||||
|     y: 73.6 | ||||
|     width: 491 | ||||
|     height: 418 | ||||
|     width: 490.8 | ||||
|     height: 418.2 | ||||
|   m_ViewDataDictionary: {fileID: 0} | ||||
|   m_OverlayCanvas: | ||||
|     m_LastAppliedPresetName: Default | ||||
| @@ -752,9 +752,9 @@ MonoBehaviour: | ||||
|   m_PlayAudio: 0 | ||||
|   m_AudioPlay: 0 | ||||
|   m_Position: | ||||
|     m_Target: {x: 12.319317, y: 1.3333886, z: 0.22287211} | ||||
|     m_Target: {x: 12.316664, y: 1.3373972, z: 0.22427776} | ||||
|     speed: 2 | ||||
|     m_Value: {x: 12.319317, y: 1.3333886, z: 0.22287211} | ||||
|     m_Value: {x: 12.316664, y: 1.3373972, z: 0.22427776} | ||||
|   m_RenderMode: 0 | ||||
|   m_CameraMode: | ||||
|     drawMode: 0 | ||||
| @@ -801,9 +801,9 @@ MonoBehaviour: | ||||
|     m_GridAxis: 1 | ||||
|     m_gridOpacity: 0.5 | ||||
|   m_Rotation: | ||||
|     m_Target: {x: 0.27131104, y: -0.4891474, z: 0.16330287, w: 0.81269896} | ||||
|     m_Target: {x: 0.2700917, y: -0.4893918, z: 0.16256894, w: 0.813105} | ||||
|     speed: 2 | ||||
|     m_Value: {x: 0.27130803, y: -0.48914197, z: 0.16330107, w: 0.81268996} | ||||
|     m_Value: {x: 0.27008873, y: -0.48938638, z: 0.16256714, w: 0.813096} | ||||
|   m_Size: | ||||
|     m_Target: 0.8347519 | ||||
|     speed: 2 | ||||
| @@ -853,9 +853,9 @@ MonoBehaviour: | ||||
|   m_Pos: | ||||
|     serializedVersion: 2 | ||||
|     x: 0 | ||||
|     y: 512 | ||||
|     y: 512.8 | ||||
|     width: 1268 | ||||
|     height: 271 | ||||
|     height: 270.8 | ||||
|   m_ViewDataDictionary: {fileID: 0} | ||||
|   m_OverlayCanvas: | ||||
|     m_LastAppliedPresetName: Default | ||||
| @@ -886,9 +886,9 @@ MonoBehaviour: | ||||
|     m_IsLocked: 0 | ||||
|   m_FolderTreeState: | ||||
|     scrollPos: {x: 0, y: 120} | ||||
|     m_SelectedIDs: de630000 | ||||
|     m_LastClickedID: 25566 | ||||
|     m_ExpandedIDs: 00000000ba630000bc630000be630000c0630000c263000000ca9a3b | ||||
|     m_SelectedIDs: 62640000 | ||||
|     m_LastClickedID: 25698 | ||||
|     m_ExpandedIDs: 00000000426400004464000046640000486400004a64000000ca9a3b | ||||
|     m_RenameOverlay: | ||||
|       m_UserAcceptedRename: 0 | ||||
|       m_Name:  | ||||
| @@ -916,7 +916,7 @@ MonoBehaviour: | ||||
|     scrollPos: {x: 0, y: 0} | ||||
|     m_SelectedIDs:  | ||||
|     m_LastClickedID: 0 | ||||
|     m_ExpandedIDs: 00000000ba630000bc630000be630000c0630000c2630000 | ||||
|     m_ExpandedIDs: 00000000426400004464000046640000486400004a640000 | ||||
|     m_RenameOverlay: | ||||
|       m_UserAcceptedRename: 0 | ||||
|       m_Name:  | ||||
| @@ -943,7 +943,7 @@ MonoBehaviour: | ||||
|   m_ListAreaState: | ||||
|     m_SelectedInstanceIDs:  | ||||
|     m_LastClickedInstanceID: 0 | ||||
|     m_HadKeyboardFocusLastEvent: 1 | ||||
|     m_HadKeyboardFocusLastEvent: 0 | ||||
|     m_ExpandedInstanceIDs: c623000030660000986f0000d65e0000 | ||||
|     m_RenameOverlay: | ||||
|       m_UserAcceptedRename: 0 | ||||
| @@ -993,9 +993,9 @@ MonoBehaviour: | ||||
|   m_Pos: | ||||
|     serializedVersion: 2 | ||||
|     x: 0 | ||||
|     y: 512 | ||||
|     y: 512.8 | ||||
|     width: 1268 | ||||
|     height: 271 | ||||
|     height: 270.8 | ||||
|   m_ViewDataDictionary: {fileID: 0} | ||||
|   m_OverlayCanvas: | ||||
|     m_LastAppliedPresetName: Default | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Noah4ever
					Noah4ever