Merge FIX

This commit is contained in:
juliuse98
2021-11-12 11:14:06 +01:00
parent dd44099bab
commit 1b0d941f07
6 changed files with 103 additions and 72 deletions

View File

@@ -115,6 +115,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 732033708985862910} - component: {fileID: 732033708985862910}
- component: {fileID: 6352645931139448055} - component: {fileID: 6352645931139448055}
- component: {fileID: 5204381087217674634}
m_Layer: 0 m_Layer: 0
m_Name: M92 m_Name: M92
m_TagString: Untagged m_TagString: Untagged
@@ -129,7 +130,7 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5071598280516985511} 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_LocalPosition: {x: 0, y: 0, z: 0.03999999}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
@@ -153,6 +154,29 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 48948dfe9d76b07488dacd46a7955fa1, type: 3} m_Script: {fileID: 11500000, guid: 48948dfe9d76b07488dacd46a7955fa1, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: 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 --- !u!1001 &1330674258901920049
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@@ -475,7 +475,7 @@ GameObject:
- component: {fileID: 3387435154213398635} - component: {fileID: 3387435154213398635}
- component: {fileID: 5630859218361338035} - component: {fileID: 5630859218361338035}
- component: {fileID: 8436279266335313624} - component: {fileID: 8436279266335313624}
- component: {fileID: 3781802212159559521} - component: {fileID: 1258077278480047560}
- component: {fileID: 320375778840406984} - component: {fileID: 320375778840406984}
- component: {fileID: 7273209952621479910} - component: {fileID: 7273209952621479910}
- component: {fileID: 6207632454083444980} - component: {fileID: 6207632454083444980}
@@ -623,6 +623,10 @@ MonoBehaviour:
AimPoint: {fileID: 2992488853448454767} AimPoint: {fileID: 2992488853448454767}
HoldPoint: {fileID: 8043317747957554736} HoldPoint: {fileID: 8043317747957554736}
isAiming: 0 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 --- !u!114 &5630859218361338035
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -665,7 +669,7 @@ MonoBehaviour:
username: username:
usernameTextObj: {fileID: 0} usernameTextObj: {fileID: 0}
health: 0 health: 0
--- !u!114 &3781802212159559521 --- !u!114 &1258077278480047560
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@@ -674,15 +678,16 @@ MonoBehaviour:
m_GameObject: {fileID: 6272346181302961293} m_GameObject: {fileID: 6272346181302961293}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc5bc2b49bd326e4db460a6a3af59311, type: 3} m_Script: {fileID: 11500000, guid: 0f43c52a1834dcb4bab807bc0cbddec2, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
syncMode: 0 syncMode: 0
syncInterval: 0.1 syncInterval: 0.1
muzzle: {fileID: 3649358604728444914} muzzle: {fileID: 3649358604728444914}
shootAnim: {fileID: 3387435154213398635} shootAnim: {fileID: 3387435154213398635}
fireRate: 320 weaponHolder: {fileID: 7768205653369755348}
gunHoldPos: {fileID: 3682030003239559187} mCamera: {fileID: 6272346181657429395}
limitAmmunition: 1
--- !u!114 &320375778840406984 --- !u!114 &320375778840406984
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994} 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 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
@@ -1233,7 +1233,7 @@ MonoBehaviour:
DebugTextGrounded: {fileID: 987854205} DebugTextGrounded: {fileID: 987854205}
DebugTextAmmunition: {fileID: 1430445133} DebugTextAmmunition: {fileID: 1430445133}
DebugTextClientServer: {fileID: 0} DebugTextClientServer: {fileID: 0}
Player: {fileID: 0} Player: {fileID: 6272346181302961293, guid: a14d876ac00bdf6498e30b3e58b68fdf, type: 3}
GameManager: {fileID: 0} GameManager: {fileID: 0}
fpsText: {fileID: 72243808} fpsText: {fileID: 72243808}
deltaTime: 0 deltaTime: 0

View File

@@ -91,7 +91,7 @@ public class ProcedualAnimationController : NetworkBehaviour
public bool isAiming = false; public bool isAiming = false;
Vector3[] positionMod = new Vector3[3]; Vector3[] positionMod = new Vector3[3];
Quaternion[] rotationMod = new Quaternion[3]; public Quaternion[] rotationMod = new Quaternion[3];
public void OnSwitchWeapon(float fireRate) public void OnSwitchWeapon(float fireRate)

View File

@@ -6,9 +6,8 @@ using TMPro;
public class Shoot : NetworkBehaviour public class Shoot : NetworkBehaviour
{ {
[SerializeField] GameObject muzzle; [SerializeField] GameObject muzzle;
[SerializeField] ShootAnimation shootAnim; [SerializeField] ProcedualAnimationController shootAnim;
[SerializeField] GameObject weaponHolder; [SerializeField] GameObject weaponHolder;
[SerializeField] GameObject GunRotation;
[SerializeField] Camera mCamera; [SerializeField] Camera mCamera;
[SerializeField] bool limitAmmunition = true; [SerializeField] bool limitAmmunition = true;
@@ -26,7 +25,10 @@ public class Shoot : NetworkBehaviour
public int TotalAmmo { get => totalAmmo; set => totalAmmo = value; } public int TotalAmmo { get => totalAmmo; set => totalAmmo = value; }
private void Start() { private void Start() {
if (isServer) {
weapon = weaponHolder.GetComponent<Weapon>();
shootAnim.OnSwitchWeapon(weapon.Firerate);
}
if (isLocalPlayer) { if (isLocalPlayer) {
weapon = weaponHolder.GetComponent<Weapon>(); weapon = weaponHolder.GetComponent<Weapon>();
shootAnim.OnSwitchWeapon(weapon.Firerate); shootAnim.OnSwitchWeapon(weapon.Firerate);
@@ -44,7 +46,9 @@ public class Shoot : NetworkBehaviour
} }
if (Input.GetButtonDown("Fire")) { if (Input.GetButtonDown("Fire")) {
updateCanvas = true; updateCanvas = true;
Debug.Log(" click");
CmdFireBullet(); CmdFireBullet();
shootAnim.Recoil(0.1f);
} }
if (Input.GetButtonDown("Reload")) { if (Input.GetButtonDown("Reload")) {
updateCanvas = true; updateCanvas = true;
@@ -65,18 +69,21 @@ public class Shoot : NetworkBehaviour
// This code will be executed on the Server. // This code will be executed on the Server.
private void CmdFireBullet() { private void CmdFireBullet() {
ray = new Ray(mCamera.transform.position, mCamera.transform.forward); // Raycast from Camera 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 hitpos = crosshairHitPoint.point; // If hitpoint is under 5000
} else { } else {
hitpos = mCamera.transform.position + mCamera.transform.forward * 5000; hitpos = mCamera.transform.position + mCamera.transform.forward * 5000;
} }
_pointDirection = hitpos - muzzle.transform.position; _pointDirection = hitpos - muzzle.transform.position;
_lookRotation = Quaternion.LookRotation(_pointDirection); _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 (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 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); Debug.DrawLine(muzzle.transform.position, hit.point);
bulletHole(GameObject.CreatePrimitive(PrimitiveType.Sphere), hit); // Creates bullethole where raycast hits bulletHole(GameObject.CreatePrimitive(PrimitiveType.Sphere), hit); // Creates bullethole where raycast hits
@@ -90,7 +97,7 @@ public class Shoot : NetworkBehaviour
subtractAmmunition(weapon); // Subtract Ammunition subtractAmmunition(weapon); // Subtract Ammunition
} }
StartCoroutine(fireRate()); StartCoroutine(fireRate());
} }
} }
void bulletHole(GameObject holeObject, RaycastHit hit) void bulletHole(GameObject holeObject, RaycastHit hit)
@@ -99,11 +106,6 @@ public class Shoot : NetworkBehaviour
holeObject.transform.position = hit.point; holeObject.transform.position = hit.point;
} }
[Client]
void shootAnimation() {
shootAnim.recoil(0.1f);
}
IEnumerator fireRate() { IEnumerator fireRate() {
weapon.AllowAction = false; weapon.AllowAction = false;

View File

@@ -45,10 +45,10 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 711.2 x: 709.60004
y: 73.6 y: 73.6
width: 457.99994 width: 459.59998
height: 451 height: 451.8
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
m_LastAppliedPresetName: Default m_LastAppliedPresetName: Default
@@ -59,7 +59,7 @@ MonoBehaviour:
m_ShowGizmos: 0 m_ShowGizmos: 0
m_TargetDisplay: 0 m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 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_TextureFilterMode: 0
m_TextureHideFlags: 61 m_TextureHideFlags: 61
m_RenderIMGUI: 1 m_RenderIMGUI: 1
@@ -74,10 +74,10 @@ MonoBehaviour:
m_VRangeLocked: 0 m_VRangeLocked: 0
hZoomLockedByDefault: 0 hZoomLockedByDefault: 0
vZoomLockedByDefault: 0 vZoomLockedByDefault: 0
m_HBaseRangeMin: -183.19998 m_HBaseRangeMin: -183.84
m_HBaseRangeMax: 183.19998 m_HBaseRangeMax: 183.84
m_VBaseRangeMin: -172 m_VBaseRangeMin: -172.31999
m_VBaseRangeMax: 172 m_VBaseRangeMax: 172.31999
m_HAllowExceedBaseRangeMin: 1 m_HAllowExceedBaseRangeMin: 1
m_HAllowExceedBaseRangeMax: 1 m_HAllowExceedBaseRangeMax: 1
m_VAllowExceedBaseRangeMin: 1 m_VAllowExceedBaseRangeMin: 1
@@ -95,23 +95,23 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 21 y: 21
width: 457.99994 width: 459.59998
height: 430 height: 430.8
m_Scale: {x: 1, y: 1} 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_MarginLeft: 0
m_MarginRight: 0 m_MarginRight: 0
m_MarginTop: 0 m_MarginTop: 0
m_MarginBottom: 0 m_MarginBottom: 0
m_LastShownAreaInsideMargins: m_LastShownAreaInsideMargins:
serializedVersion: 2 serializedVersion: 2
x: -228.99997 x: -229.79999
y: -215 y: -215.4
width: 457.99994 width: 459.59998
height: 430 height: 430.8
m_MinimalGUI: 1 m_MinimalGUI: 1
m_defaultScale: 1 m_defaultScale: 1
m_LastWindowPixelSize: {x: 572.49994, y: 563.75} m_LastWindowPixelSize: {x: 574.5, y: 564.75}
m_ClearInEditMode: 1 m_ClearInEditMode: 1
m_NoCameraWarning: 1 m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000 m_LowResolutionForAspectRatios: 01000000000000000000
@@ -163,7 +163,7 @@ MonoBehaviour:
x: 0 x: 0
y: 0 y: 0
width: 1171.2 width: 1171.2
height: 472 height: 472.8
m_MinSize: {x: 300, y: 100} m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 8096} m_MaxSize: {x: 24288, y: 8096}
vertical: 0 vertical: 0
@@ -185,10 +185,10 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 296 width: 293.6
height: 472 height: 472.8
m_MinSize: {x: 201, y: 221} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4001, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 6} m_ActualView: {fileID: 6}
m_Panes: m_Panes:
- {fileID: 6} - {fileID: 6}
@@ -216,8 +216,8 @@ MonoBehaviour:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 73.6 y: 73.6
width: 295 width: 292.6
height: 451 height: 451.8
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
m_LastAppliedPresetName: Default m_LastAppliedPresetName: Default
@@ -227,7 +227,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: 2afbffff m_ExpandedIDs: deecfeff30edfeff98effeff20fafeff72fafeffdafcfeff4c06ffffa606ffff0e09ffff6613ffffb813ffff2016ffffd81effff2a1fffff9221ffff442effff962efffffe30ffff7038ffffc238ffff2a3bffff3441ffff8841fffff043ffffc258ffff1459ffff7c5bffff6a62ffffc462ffff2c65ffffd86fffff2a70ffff9272ffff6680ffffb880ffff2083ffff408affff928afffffa8cffffb893ffff0a94ffff7296ffff3499ffff8699ffffee9bffff269effff789effffe0a0ffffa2abffffaaabffffb0abffffdcabffff50eeffff2afbffff
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@@ -266,10 +266,10 @@ MonoBehaviour:
m_Children: [] m_Children: []
m_Position: m_Position:
serializedVersion: 2 serializedVersion: 2
x: 296 x: 293.6
y: 0 y: 0
width: 415.2 width: 415.99997
height: 472 height: 472.8
m_MinSize: {x: 200, y: 200} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 9} m_ActualView: {fileID: 9}
@@ -362,10 +362,10 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 296 x: 293.6
y: 73.6 y: 73.6
width: 413.2 width: 413.99997
height: 451 height: 451.8
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
m_LastAppliedPresetName: Default m_LastAppliedPresetName: Default
@@ -430,9 +430,9 @@ MonoBehaviour:
floating: 0 floating: 0
collapsed: 0 collapsed: 0
displayed: 1 displayed: 1
snapOffset: {x: 67.5, y: 86} snapOffset: {x: -171.7, y: 86}
snapOffsetDelta: {x: 0, y: 0} snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0 snapCorner: 1
id: Orientation id: Orientation
index: 0 index: 0
layout: 4 layout: 4
@@ -673,10 +673,10 @@ MonoBehaviour:
m_Children: [] m_Children: []
m_Position: m_Position:
serializedVersion: 2 serializedVersion: 2
x: 711.2 x: 709.6
y: 0 y: 0
width: 459.99994 width: 461.59998
height: 472 height: 472.8
m_MinSize: {x: 200, y: 200} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 2} m_ActualView: {fileID: 2}
@@ -700,9 +700,9 @@ MonoBehaviour:
m_Position: m_Position:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 472 y: 472.8
width: 1171.2 width: 1171.2
height: 258.8 height: 258
m_MinSize: {x: 100, y: 100} m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 13} m_ActualView: {fileID: 13}
@@ -731,10 +731,10 @@ MonoBehaviour:
m_Tooltip: m_Tooltip:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 1536 x: 0
y: 684 y: 546.4
width: 1463 width: 1170.2
height: 315 height: 237
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
m_LastAppliedPresetName: Default m_LastAppliedPresetName: Default
@@ -752,22 +752,22 @@ MonoBehaviour:
m_SkipHidden: 0 m_SkipHidden: 0
m_SearchArea: 1 m_SearchArea: 1
m_Folders: m_Folders:
- Assets/Scenes - Assets/Prefabs/Player
m_Globs: [] m_Globs: []
m_OriginalText: m_OriginalText:
m_ViewMode: 1 m_ViewMode: 1
m_StartGridSize: 64 m_StartGridSize: 64
m_LastFolders: m_LastFolders:
- Assets/Scenes - Assets/Prefabs/Player
m_LastFoldersGridSize: -1 m_LastFoldersGridSize: -1
m_LastProjectPath: C:\Users\juliu\Desktop\Ausbildung\Fps-build\3d-shooter m_LastProjectPath: C:\Users\juliu\Desktop\Ausbildung\Fps-build\3d-shooter
m_LockTracker: m_LockTracker:
m_IsLocked: 0 m_IsLocked: 0
m_FolderTreeState: m_FolderTreeState:
scrollPos: {x: 0, y: 120} scrollPos: {x: 0, y: 167}
m_SelectedIDs: d8640000 m_SelectedIDs: 16650000
m_LastClickedID: 25816 m_LastClickedID: 25878
m_ExpandedIDs: 000000000a6300000c6300000e630000 m_ExpandedIDs: 000000000a6300000c6300000e630000dc640000e064000000ca9a3bffffff7f
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@@ -872,9 +872,9 @@ MonoBehaviour:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 545.60004 y: 546.4
width: 1170.2 width: 1170.2
height: 237.79999 height: 237
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
m_LastAppliedPresetName: Default m_LastAppliedPresetName: Default