private void TakeGun(GunBase gun) { var rb = gun.GetComponent <Rigidbody>(); if (rb != null) { rb.detectCollisions = false; rb.isKinematic = true; } gun.transform.SetPositionAndRotation(gunPoint.position, gunPoint.rotation); gun.transform.parent = gunPoint; gun.playerNumber = playerNumber; gun.playerRigidbody = bodyRigidbody; equippedGun = gun; }
private void DropGun() { if (equippedGun == null) { return; } var rb = equippedGun.GetComponent <Rigidbody>(); if (rb != null) { rb.detectCollisions = true; rb.isKinematic = false; } equippedGun.transform.parent = null; equippedGun.playerNumber = -1; equippedGun.playerRigidbody = null; equippedGun = null; }