mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
Little fix on player, added trigger collider on usp
@juliuse98 needs to fix when looking up the weapon gets to far away an the hands look strange. Tried to fix it a bit. Its no a little better but NOT completely fixed. USP has now a collider that is a trigger. When the weapon is clipping through the wall (befor that the collider should trigger and the player puts the weapon upright) ITS NOT WORKING but the structure is there... (All collider gets disabled when you pick up a weapon)
This commit is contained in:
@@ -259,6 +259,8 @@ public class ProcedualAnimationController : NetworkBehaviour
|
||||
{
|
||||
if (positionMod[i] != null)
|
||||
totalPosition += positionMod[i];
|
||||
//if (i == 3)
|
||||
//Debug.Log(positionMod[i]);
|
||||
}
|
||||
|
||||
/*-----Apply Gun Rotation-----*/
|
||||
@@ -302,18 +304,21 @@ public class ProcedualAnimationController : NetworkBehaviour
|
||||
aimVal = gravityValue(aimVal, aimSpeed, 1, 0, isAiming);
|
||||
positionMod[2] = Vector3.Lerp(HoldPoint.transform.localPosition, AimPoint.transform.localPosition, Mathf.Pow(aimVal, 1.3f));
|
||||
}
|
||||
|
||||
public void weaponToCloseToWall(bool state) {
|
||||
int lineNumber = (new System.Diagnostics.StackFrame(0, true)).GetFileLineNumber(); // Only for debugging
|
||||
//Debug.Log("PAC.cs (function at line:" + (lineNumber-1) + "): Weapon is to close to wall: Weapon should get upright or to normal position now depending on state!");
|
||||
}
|
||||
public void changePistole(bool isSwitching) { // Moves hands doooown ;) and up again NOT WORKING
|
||||
//aimVal = gravityValue(aimVal, aimSpeed, 1, 0, isSwitching);
|
||||
Vector3 b = new Vector3(HoldPoint.transform.localPosition.x, 1, HoldPoint.transform.localPosition.z);
|
||||
//Debug.Log("HALLO: " + positionMod[3]);
|
||||
//Debug.Log("PositionMod[3]: " + positionMod[3]);
|
||||
positionMod[3] = Vector3.Lerp(HoldPoint.transform.localPosition, b, 0.5f);
|
||||
//Debug.Log("HALLO: " + positionMod[3]);
|
||||
//Debug.Log("PositionMod[3]: " + positionMod[3]);
|
||||
}
|
||||
public void changeRifle(bool isSwitching) { // Moves hands up and doooown again ;)
|
||||
//aimVal = gravityValue(aimVal, aimSpeed, 1, 0, isSwitching);
|
||||
Vector3 b = new Vector3(HoldPoint.transform.localPosition.x, HoldPoint.transform.localPosition.y + 1, HoldPoint.transform.localPosition.z);
|
||||
positionMod[3] = Vector3.Lerp(HoldPoint.transform.localPosition, b, 0);
|
||||
//Vector3 b = new Vector3(HoldPoint.transform.localPosition.x, HoldPoint.transform.localPosition.y + 1, HoldPoint.transform.localPosition.z);
|
||||
//positionMod[3] = Vector3.Lerp(HoldPoint.transform.localPosition, b, 0);
|
||||
//Debug.Log("HALLO2");
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public class Shoot : NetworkBehaviour
|
||||
}
|
||||
|
||||
public bool setWeapon(GameObject newWeapon) {
|
||||
Debug.Log("Switch weapon to: " + newWeapon.transform.name);
|
||||
//Debug.Log("Switch weapon to: " + newWeapon.transform.name);
|
||||
weapon = newWeapon.GetComponent<Weapon>();
|
||||
curAmmo = weapon.CurrentAmmunition;
|
||||
totalAmmo = weapon.TotalAmmunition;
|
||||
|
||||
@@ -19,6 +19,7 @@ public class Weapon : MonoBehaviour
|
||||
[SerializeField] int magazinSize = 0;
|
||||
[SerializeField] int totalAmmunition = 0;
|
||||
[SerializeField] GameObject bulletExit;
|
||||
[SerializeField] bool toCloseToWall = false;
|
||||
[SerializeField] bool allowAction = true;
|
||||
[Header("")]
|
||||
[SerializeField] Animator weaponAnimator;
|
||||
@@ -37,6 +38,7 @@ public class Weapon : MonoBehaviour
|
||||
public int MagazinSize { get => magazinSize; set => magazinSize = value; }
|
||||
public int TotalAmmunition { get => totalAmmunition; set => totalAmmunition = value; }
|
||||
public GameObject BulletExit { get => bulletExit; }
|
||||
public bool ToCloseToWall { get => toCloseToWall; set => toCloseToWall = value; }
|
||||
public bool AllowAction { get => allowAction; set => allowAction = value; }
|
||||
public Animator WeaponAnimator { get => weaponAnimator; }
|
||||
public Transform GunLeftREF { get => gunLeftREF; }
|
||||
@@ -48,4 +50,13 @@ public class Weapon : MonoBehaviour
|
||||
CurrentAmmunition = MagazinSize;
|
||||
}
|
||||
|
||||
// When to close to a wall, the player puts the weapon upright (Change size on weapon collider where isTrigger == true)
|
||||
/*private void OnCollisionEnter(Collision collision) {
|
||||
toCloseToWall = true;
|
||||
Debug.Log(collision.transform.name);
|
||||
}
|
||||
private void OnCollisionExit(Collision collision) {
|
||||
toCloseToWall = false;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ using Mirror;
|
||||
|
||||
public class WeaponManager : NetworkBehaviour
|
||||
{
|
||||
public int currentWeaponIndex = 0;
|
||||
public int currentWeaponIndex = 2; // Hand
|
||||
private int lastWeaponIndex = 0;
|
||||
private int counter = 0;
|
||||
public List<GameObject> activeWeapons = new List<GameObject>();
|
||||
private ProcedualAnimationController procedualAnimationController;
|
||||
private Weapon weaponData;
|
||||
|
||||
[SerializeField] Shoot shoot;
|
||||
[SerializeField] GameObject gunHolster;
|
||||
@@ -20,6 +20,8 @@ public class WeaponManager : NetworkBehaviour
|
||||
private void Awake()
|
||||
{
|
||||
procedualAnimationController = GetComponent<ProcedualAnimationController>();
|
||||
currentWeaponIndex = 2; // Hand
|
||||
weaponData = activeWeapons[currentWeaponIndex].GetComponent<Weapon>(); // Hand
|
||||
}
|
||||
|
||||
void Update() {
|
||||
@@ -45,13 +47,23 @@ public class WeaponManager : NetworkBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate() {
|
||||
/*if(currentWeaponIndex != 2) {
|
||||
if (weaponData.ToCloseToWall) {
|
||||
procedualAnimationController.weaponToCloseToWall(true);
|
||||
} else {
|
||||
procedualAnimationController.weaponToCloseToWall(false);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public bool switchWeapon(int direction) {
|
||||
// Get next active weapon index
|
||||
int nextActive = searchForNext(activeWeapons, lastWeaponIndex, direction);
|
||||
currentWeaponIndex = nextActive;
|
||||
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
|
||||
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
|
||||
Weapon weaponData = activeWeapons[currentWeaponIndex].GetComponent<Weapon>();
|
||||
weaponData = activeWeapons[currentWeaponIndex].GetComponent<Weapon>();
|
||||
procedualAnimationController.GunRightHandREF = weaponData.GunRightREF;
|
||||
procedualAnimationController.GunLeftHandREF = weaponData.GunLeftREF;
|
||||
// Play weapon switch animation
|
||||
@@ -111,7 +123,7 @@ public class WeaponManager : NetworkBehaviour
|
||||
hit.rigidbody.useGravity = false;
|
||||
// Disable all Collider
|
||||
SetAllColliderStatus(hit.transform.gameObject, false);
|
||||
// Adding weapon to inventory slot
|
||||
// Adding weapon to correct inventory slot
|
||||
switch (hit.transform.GetComponent<Weapon>().WeaponKind.ToString()) {
|
||||
case "Rifle": putWeaponInArray(0, hit); break;
|
||||
case "Pistole": putWeaponInArray(1, hit); break;
|
||||
|
||||
Reference in New Issue
Block a user