Fixed some issues.
Grenades work now.
This commit is contained in:
Noah4ever
2021-12-08 17:18:23 +01:00
parent 56f5aec9cc
commit 59a55bf5fd
4 changed files with 155 additions and 118 deletions

View File

@@ -1,17 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &867143322194457524
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2213212323547960416}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48948dfe9d76b07488dacd46a7955fa1, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &2236875552107647873
GameObject:
m_ObjectHideFlags: 0
@@ -168,11 +156,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c98f5c47a8b7dd64f86fd6f42c4d6e5e, type: 3}
m_Name:
m_EditorClassIdentifier:
weaponKind: 1
active: 0
weaponKind: 3
dropForce: 20
damage: 15
firerate: 320
roundsPerShot: 1
recoilStrength: 15
currentAmmunition: 8
magazinSize: 16
@@ -182,6 +169,12 @@ MonoBehaviour:
weaponAnimator: {fileID: 4836044225623250080}
gunRightREF: {fileID: 5792494204646893847}
gunLeftREF: {fileID: 808197646603973991}
isGrenade: 1
timer: 2
explosionForce: 2
grenadeRadius: 3
hasExploded: 0
hasBeenThrown: 1
--- !u!65 &3937508078766297979
BoxCollider:
m_ObjectHideFlags: 0
@@ -193,8 +186,8 @@ BoxCollider:
m_IsTrigger: 0
m_Enabled: 0
serializedVersion: 2
m_Size: {x: 0.040187918, y: 0.16860102, z: 0.2560755}
m_Center: {x: 0.00017769728, y: -0.07880532, z: -0.26860136}
m_Size: {x: 0.067302436, y: 0.20004939, z: 0.27977693}
m_Center: {x: 0.0137349535, y: -0.06308114, z: -0.28045207}
--- !u!54 &2072484884
Rigidbody:
m_ObjectHideFlags: 0
@@ -287,3 +280,15 @@ Animator:
m_CorrespondingSourceObject: {fileID: 5866666021909216657, guid: d1ac7df45c0d7e84993ff57afe3c4d6f, type: 3}
m_PrefabInstance: {fileID: 1330674258901920049}
m_PrefabAsset: {fileID: 0}
--- !u!114 &867143322194457524
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2213212323547960416}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 48948dfe9d76b07488dacd46a7955fa1, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@@ -136,7 +136,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.x
value: 11.294186
value: 12.38
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.y
@@ -182,6 +182,18 @@ PrefabInstance:
propertyPath: m_Name
value: M92 (1)
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: dropForce
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: isGrenade
value: 0
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!1 &39659576 stripped
@@ -651,33 +663,20 @@ PrefabInstance:
propertyPath: m_TagString
value: Weapon
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: dropForce
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: isGrenade
value: 0
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!1 &445037169 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 6930424391121909826, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
m_PrefabInstance: {fileID: 6930424391482245683}
m_PrefabAsset: {fileID: 0}
--- !u!54 &445037176
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 445037169}
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 &450235891 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: -466329591000292508, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3}
@@ -1409,6 +1408,87 @@ MeshCollider:
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: -629719859055844128, guid: 823e8b39d52b71b4eb5a91dbc8d6d59e, type: 3}
--- !u!1001 &1243110492
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 0}
propertyPath: explodeParticle
value:
objectReference: {fileID: 1541885955888442623}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_RootOrder
value: 12
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.x
value: 8.51
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.y
value: 1.43
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.z
value: 0.93
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: 3937508078766297979, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5071598280516985511, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_Name
value: Grenade
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: dropForce
value: 15
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: grenadeRadius
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: hasBeenThrown
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: explosionForce
value: 300
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
--- !u!1 &1246681035
GameObject:
m_ObjectHideFlags: 0
@@ -1909,15 +1989,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.x
value: 11.773485
value: 14.89
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.y
value: 0.483
value: 0.389
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalPosition.z
value: 1.6332005
value: -0.141
objectReference: {fileID: 0}
- target: {fileID: 732033708985862910, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: m_LocalRotation.w
@@ -1955,6 +2035,18 @@ PrefabInstance:
propertyPath: m_Name
value: M92 (2)
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: dropForce
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5204381087217674634, guid: bd217f9f85ce78e46a925776562625e8, type: 3}
propertyPath: isGrenade
value: 0
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!1 &1683546023 stripped
@@ -2408,7 +2500,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
propertyPath: m_RootOrder
value: 12
value: 11
objectReference: {fileID: 0}
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
propertyPath: m_LocalPosition.x
@@ -2416,7 +2508,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
propertyPath: m_LocalPosition.y
value: 2.24
value: 3.588
objectReference: {fileID: 0}
- target: {fileID: 3147283493333612388, guid: a8150377575143e4ba9ff51ba16504aa, type: 3}
propertyPath: m_LocalPosition.z
@@ -2538,67 +2630,6 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f0c1bca3291086d449266d9ed8942180, type: 3}
--- !u!1001 &6930424391482245683
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6930424391121909826, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_Name
value: Grenade
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_RootOrder
value: 11
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalPosition.x
value: 18.046112
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalPosition.y
value: 1.8965256
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalPosition.z
value: -9.051534
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6930424391121909828, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8559554177058791497, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
propertyPath: explodeParticle
value:
objectReference: {fileID: 1541885955888442623}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: dbdc6c009fc3f6144933dcf93b67f8cb, type: 3}
--- !u!1001 &8307265127065581321
PrefabInstance:
m_ObjectHideFlags: 0

View File

@@ -79,6 +79,7 @@ public class Shoot : NetworkBehaviour
// Throws grenade with dropForce
weapon.HasBeenThrown = true;
weaponManager.dropWeapon(weapon.DropForce);
weaponManager.switchWeapon(1);
}
[Command]
@@ -138,6 +139,7 @@ public class Shoot : NetworkBehaviour
}
public bool setWeapon(GameObject newWeapon) {
Debug.Log("Switch weapon to: " + newWeapon.transform.name);
weapon = newWeapon.GetComponent<Weapon>();
curAmmo = weapon.CurrentAmmunition;
totalAmmo = weapon.TotalAmmunition;

View File

@@ -39,10 +39,10 @@ public class WeaponManager : NetworkBehaviour
}
if (Input.GetButtonDown("Interact")) { // e
PickupWeapon();
}else if (Input.GetButtonDown("Drop")) { // q Droping weapon
if (activeWeapons[currentWeaponIndex] != null) {
dropWeapon(activeWeapons[currentWeaponIndex].GetComponent<Weapon>().DropForce); // Throws weapon away
switchWeapon(1);
activeWeapons[currentWeaponIndex].SetActive(true);
}
}
@@ -50,18 +50,18 @@ public class WeaponManager : NetworkBehaviour
}
private bool switchWeapon(int direction) {
public bool switchWeapon(int direction) {
// Get next active weapon index
int nextActive = searchForNext(activeWeapons, lastWeaponIndex, direction);
currentWeaponIndex = nextActive;
currentWeaponIndex = nextActive;
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
Weapon weaponData = activeWeapons[currentWeaponIndex].GetComponent<Weapon>();
procedualAnimationController.GunRightHandREF = weaponData.GunRightREF;
procedualAnimationController.GunLeftHandREF = weaponData.GunLeftREF;
// play weapon switch animation
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
Weapon weaponData = activeWeapons[currentWeaponIndex].GetComponent<Weapon>();
procedualAnimationController.GunRightHandREF = weaponData.GunRightREF;
procedualAnimationController.GunLeftHandREF = weaponData.GunLeftREF;
// play weapon switch animation
return false;
}
@@ -117,7 +117,7 @@ public class WeaponManager : NetworkBehaviour
}
private bool putWeaponInArray(int index, RaycastHit hit) {
if (activeWeapons[currentWeaponIndex] != null) {
if (activeWeapons[index] != null) {
dropWeapon(activeWeapons[currentWeaponIndex].GetComponent<Weapon>().DropForce); // Throws weapon away
}
activeWeapons[index] = hit.transform.gameObject;
@@ -138,11 +138,10 @@ public class WeaponManager : NetworkBehaviour
Rigidbody rigid = currentWeapon.GetComponent<Rigidbody>();
rigid.useGravity = true;
rigid.isKinematic = false;
rigid.velocity = cam.transform.forward * 10 + cam.transform.up * 2;
rigid.velocity = cam.transform.forward * dropForce + cam.transform.up * 2;
currentWeapon.GetComponent<BoxCollider>().enabled = true;
currentWeapon.gameObject.transform.SetParent(null);
activeWeapons[currentWeaponIndex] = null;
switchWeapon(1);
return true;
}
else {