Fixed Pickup Bug

Pickup weapon that was not in your hand lead to one weapon being "deleted"
0 Rifle (null)
1 Pistole (M92)
2 Hand (Hand)
3 Knife (null)
When u had the "Hand" equipped and picked up another Pistole (e.g. USP), M92 would not be accessable anymore.
ITS NOW FIXED! DAS IST WAS ZÄHLT!
This commit is contained in:
Noah4ever
2021-12-01 13:01:32 +01:00
parent 253b70071f
commit 64cadf0a35
2 changed files with 105 additions and 106 deletions

View File

@@ -41,7 +41,7 @@ public class WeaponManager : NetworkBehaviour
}else if (Input.GetButtonDown("Drop")) { // q Droping weapon
if (activeWeapons[currentWeaponIndex] != null) {
dropWeapon(); // Throws weapon away
dropWeapon(currentWeaponIndex); // Throws weapon away
switchWeapon(1);
activeWeapons[currentWeaponIndex].SetActive(true);
}
@@ -117,8 +117,8 @@ public class WeaponManager : NetworkBehaviour
}
private bool putWeaponInArray(int index, RaycastHit hit) {
if (activeWeapons[currentWeaponIndex] != null) {
dropWeapon(); // Throws weapon away
if (activeWeapons[index] != null) {
dropWeapon(index); // Throws weapon away
}
activeWeapons[index] = hit.transform.gameObject;
activeWeapons[index].SetActive(true);
@@ -131,9 +131,9 @@ public class WeaponManager : NetworkBehaviour
return true;
}
private bool dropWeapon() {
if(currentWeaponIndex != 2) {
GameObject currentWeapon = activeWeapons[currentWeaponIndex];
private bool dropWeapon(int index) {
if(index != 2) {
GameObject currentWeapon = activeWeapons[index];
currentWeapon.SetActive(true);
Rigidbody rigid = currentWeapon.GetComponent<Rigidbody>();
rigid.useGravity = true;
@@ -141,7 +141,7 @@ public class WeaponManager : NetworkBehaviour
rigid.velocity = cam.transform.forward * 10 + cam.transform.up * 2;
currentWeapon.GetComponent<BoxCollider>().enabled = true;
currentWeapon.gameObject.transform.SetParent(null);
activeWeapons[currentWeaponIndex] = null;
activeWeapons[index] = null;
return true;
}

View File

@@ -45,7 +45,7 @@ MonoBehaviour:
x: 0
y: 0
width: 1536
height: 781
height: 780.8
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
m_UseTopView: 1
@@ -90,7 +90,7 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 761
y: 760.8
width: 1536
height: 20
m_MinSize: {x: 0, y: 0}
@@ -115,11 +115,11 @@ MonoBehaviour:
x: 0
y: 30
width: 1536
height: 731
height: 730.8
m_MinSize: {x: 400, y: 200}
m_MaxSize: {x: 32384, y: 16192}
vertical: 0
controlID: 267
controlID: 51
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -140,11 +140,11 @@ MonoBehaviour:
x: 0
y: 0
width: 1252
height: 731
height: 730.8
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 1
controlID: 268
controlID: 52
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -166,11 +166,11 @@ MonoBehaviour:
x: 0
y: 0
width: 1252
height: 439.2
height: 630.4
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 8096}
vertical: 0
controlID: 269
controlID: 53
--- !u!114 &8
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -188,10 +188,10 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 194.4
height: 439.2
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
width: 193.6
height: 630.4
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 14}
m_Panes:
- {fileID: 14}
@@ -212,12 +212,12 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 194.4
x: 193.6
y: 0
width: 409.6
height: 439.2
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
width: 551.19995
height: 630.4
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 16}
m_Panes:
- {fileID: 15}
@@ -239,10 +239,10 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 604
x: 744.8
y: 0
width: 648
height: 439.2
width: 507.2
height: 630.4
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {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.2
y: 630.4
width: 1252
height: 291.8
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
m_ActualView: {fileID: 17}
height: 100.39996
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
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
@@ -295,9 +295,9 @@ MonoBehaviour:
x: 1252
y: 0
width: 284
height: 731
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
height: 730.8
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 19}
m_Panes:
- {fileID: 19}
@@ -323,10 +323,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 604
x: 744.8
y: 73.6
width: 646
height: 418.2
width: 505.2
height: 609.4
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: 646, y: 397.2}
m_TargetSize: {x: 505.2, y: 588.4}
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
@@ -352,10 +352,10 @@ MonoBehaviour:
m_VRangeLocked: 0
hZoomLockedByDefault: 0
vZoomLockedByDefault: 0
m_HBaseRangeMin: -258.4
m_HBaseRangeMax: 258.4
m_VBaseRangeMin: -158.88
m_VBaseRangeMax: 158.88
m_HBaseRangeMin: -202.08
m_HBaseRangeMax: 202.08
m_VBaseRangeMin: -235.36002
m_VBaseRangeMax: 235.36002
m_HAllowExceedBaseRangeMin: 1
m_HAllowExceedBaseRangeMax: 1
m_VAllowExceedBaseRangeMin: 1
@@ -373,23 +373,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
width: 646
height: 397.2
m_Scale: {x: 1.1919038, y: 1.1919038}
m_Translation: {x: 323, y: 198.6}
width: 505.2
height: 588.4
m_Scale: {x: 1, y: 1}
m_Translation: {x: 252.6, y: 294.2}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -270.99503
y: -166.62419
width: 541.99005
height: 333.24838
x: -252.6
y: -294.2
width: 505.2
height: 588.4
m_MinimalGUI: 1
m_defaultScale: 1
m_LastWindowPixelSize: {x: 807.5, y: 522.75}
m_LastWindowPixelSize: {x: 631.5, y: 761.75}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000
@@ -417,8 +417,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 73.6
width: 193.4
height: 418.2
width: 192.6
height: 609.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -426,23 +426,23 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 3e6b0000
m_LastClickedID: 27454
m_ExpandedIDs: 34e3ffff40e3ffff446b0000826b0000886b0000966b0000986b00009a6b0000
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: caa5ffff1cf4ffff2afbffff025f0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
m_OriginalName:
m_Name: Player UI
m_OriginalName: Player UI
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 0
m_UserData: -23448
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 11
m_OriginalEventType: 0
m_IsRenamingFilename: 0
m_ClientGUIView: {fileID: 8}
m_SearchString:
@@ -553,10 +553,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 194.40001
x: 193.6
y: 73.6
width: 407.6
height: 418.2
width: 549.19995
height: 609.4
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -600,7 +600,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 1
id: unity-search-toolbar
index: 1
@@ -633,7 +633,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Light Settings
index: 0
@@ -655,7 +655,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Cloth Constraints
index: 2
@@ -666,7 +666,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Cloth Collisions
index: 3
@@ -677,7 +677,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Navmesh Display
index: 4
@@ -688,7 +688,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Agent Display
index: 5
@@ -699,7 +699,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Obstacle Display
index: 6
@@ -710,7 +710,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Occlusion Culling
index: 7
@@ -721,7 +721,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Physics Debugger
index: 8
@@ -732,7 +732,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Scene Visibility
index: 9
@@ -743,7 +743,7 @@ MonoBehaviour:
collapsed: 0
displayed: 0
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: 0, y: 24.8}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: Scene View/Particles
index: 10
@@ -752,7 +752,7 @@ MonoBehaviour:
containerId: overlay-container--right
floating: 0
collapsed: 0
displayed: 1
displayed: 0
snapOffset: {x: 0, y: 25}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
@@ -761,17 +761,17 @@ MonoBehaviour:
layout: 4
m_WindowGUID: cc27987af1a868c49b0894db9c0f5429
m_Gizmos: 0
m_OverrideSceneCullingMask: 0
m_SceneIsLit: 0
m_OverrideSceneCullingMask: 6917529027641081856
m_SceneIsLit: 1
m_SceneLighting: 1
m_2DMode: 0
m_isRotationLocked: 0
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 0.1277141, y: 3.8030603, z: -0.017456843}
m_Target: {x: -46.829735, y: 466.34882, z: 248.2086}
speed: 2
m_Value: {x: 10.9051895, y: 3.3461263, z: 8.300079}
m_Value: {x: -46.829735, y: 466.34882, z: 248.2086}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@@ -783,7 +783,7 @@ MonoBehaviour:
m_SceneViewState:
m_AlwaysRefresh: 0
showFog: 1
showSkybox: 0
showSkybox: 1
showFlares: 1
showImageEffects: 1
showParticleSystems: 1
@@ -818,20 +818,20 @@ MonoBehaviour:
m_GridAxis: 1
m_gridOpacity: 0.5
m_Rotation:
m_Target: {x: -0.057347883, y: 0.942116, z: -0.24952282, w: -0.21652032}
m_Target: {x: -0.144675, y: -0.7849369, z: 0.19987676, w: -0.5683781}
speed: 2
m_Value: {x: 0.14027107, y: -0.802565, z: 0.20790805, w: 0.5412835}
m_Value: {x: -0.14497021, y: -0.78405946, z: 0.19965342, w: -0.5695374}
m_Size:
m_Target: 0.45841318
m_Target: 41.397533
speed: 2
m_Value: 0.48001382
m_Value: 37.97939
m_Ortho:
m_Target: 0
speed: 2
m_Value: 0
m_CameraSettings:
m_Speed: 1
m_SpeedNormalized: 0.5
m_Speed: 2
m_SpeedNormalized: 1
m_SpeedMin: 0.001
m_SpeedMax: 2
m_EasingEnabled: 1
@@ -870,17 +870,16 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 512.8
y: 512
width: 1251
height: 270.8
height: 271
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
m_SaveData: []
m_SearchFilter:
m_NameFilter:
m_ClassNames:
- Prefab
m_ClassNames: []
m_AssetLabels: []
m_AssetBundleNames: []
m_VersionControlStates: []
@@ -889,14 +888,14 @@ MonoBehaviour:
m_SceneHandles:
m_ShowAllHits: 0
m_SkipHidden: 0
m_SearchArea: 1
m_SearchArea: 0
m_Folders: []
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 64
m_LastFolders:
- Assets
- Assets/Maps/Japan
m_LastFoldersGridSize: -1
m_LastProjectPath: D:\.Downloads\Programming\Unity\Projects\Rheinmetall\3dshooter\3d-shooter
m_LockTracker:
@@ -905,7 +904,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 04ca9a3b
m_LastClickedID: 1000000004
m_ExpandedIDs: 0000000086640000886400008a6400008c6400008e64000000ca9a3b
m_ExpandedIDs: 00000000f0610000f2610000f4610000f6610000f86100000862000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -933,7 +932,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 0000000086640000886400008a6400008c6400008e640000
m_ExpandedIDs: 00000000f0610000f2610000f4610000f6610000f8610000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -958,10 +957,10 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_ListAreaState:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_SelectedInstanceIDs: 965e0000
m_LastClickedInstanceID: 24214
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c623000030660000986f0000d65e0000866c00009e60000036650000
m_ExpandedInstanceIDs: c623000030660000986f0000d65e0000866c00009e6000003665000086620000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -977,7 +976,7 @@ MonoBehaviour:
m_IsRenaming: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 11}
m_ClientGUIView: {fileID: 9}
m_CreateAssetUtility:
m_EndAction: {fileID: 0}
m_InstanceID: 0
@@ -1010,9 +1009,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 512.8
y: 704
width: 1251
height: 270.8
height: 79.39996
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -1040,7 +1039,7 @@ MonoBehaviour:
x: 1252
y: 73.6
width: 283
height: 710
height: 709.8
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -1048,7 +1047,7 @@ MonoBehaviour:
m_ObjectsLockedBeforeSerialization: []
m_InstanceIDsLockedBeforeSerialization:
m_PreviewResizer:
m_CachedPref: 151
m_CachedPref: 171
m_ControlHash: -371814159
m_PrefName: Preview_InspectorPreview
m_LastInspectedObjectInstanceID: -1