mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 20:52:10 +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:
@@ -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