public void DropWeapon(InputAction.CallbackContext idk = new InputAction.CallbackContext())
{
Debug.Log(currentWeapon);
if (HasWeapon)
{
Rigidbody pickup = Object.Instantiate(pickupPrefab, weaponTip.position, weaponTip.rotation).GetComponent<Rigidbody>();
pickup.AddForce(weaponTip.forward * throwForce, ForceMode.Impulse);
pickup.AddTorque(weaponTip.up * Random.Range(-1f, 1f) * 20, ForceMode.Impulse);
pickup.GetComponent<WeaponPickupManager>().SetWeapon(currentWeapon, currentAmmo);
currentAmmo = 0;
currentWeapon = null;
}
}
#idk
1 messages · Page 1 of 1 (latest)
I commented out the first method and made the parameter optional, so both this:
and this :
call the exact same function.
The problem is still there
when called from the action.performed event, the function will short-curcuit because it identifies this variable:
as null.
WHEN IT HAS AN OBJECT ASSIGNED TO IT