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:
- 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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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<Weapon>();
shootAnim.OnSwitchWeapon(weapon.Firerate);
}
if (isLocalPlayer) {
weapon = weaponHolder.GetComponent<Weapon>();
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;