void PickUp(string inputbonus) { if (holding != null) { holding.transform.position = center + armFacingVector * (reach + holding.GetSize()) + new Vector3(0f, Mathf.Clamp(playerHoldingHeigth * ((Time.time - pickUpStartTime) * 10f), 0f, playerHoldingHeigth), 0f); holdingrotate = Vector2.Angle(new Vector2(armFacingVector.x, armFacingVector.z), new Vector2(holdingAngle.x, holdingAngle.z)); Vector3 cross = Vector3.Cross(new Vector2(armFacingVector.x, armFacingVector.z), new Vector2(holdingAngle.x, holdingAngle.z)); if (cross.z < 0) { holdingrotate = 360 - holdingrotate; } holding.transform.rotation = Quaternion.LookRotation(Quaternion.AngleAxis(holdingrotate, Vector3.up) * Vector3.right); } if (Input.GetAxis("PickUp" + inputbonus) < 0 || Input.GetAxis("PickUp" + inputbonus) > 0) { if (holding == null) { RaycastHit[] hits = Physics.BoxCastAll(center, new Vector3(0.1f, 0.1f, 0.1f), armFacingVector, Quaternion.identity, reach); for (int i = 0; i < hits.Length; i++) { Pickup temp = hits[i].transform.GetComponent<Pickup>(); if (temp != null) { SoundController.Instance.PlayFX("Mech_PickUp", transform.position); temp.OnPickedUp(this); holding = temp; holding.transform.position = (center + armFacingVector * (reach + holding.GetSize())); holdingAngle = (holding.transform.position - transform.position).normalized; holdingrotate = 0; pickUpStartTime = Time.time + 0.25f; animTop.SetBool("pickingUp", true); GetComponent<Weight>().AddWeight(holding.gameObject.GetComponent<Weight>().GetWeight()); } if (hits[i].transform.GetComponent<InteractiveButton>() != null && !isPressing) { SoundController.Instance.PlayFX("Mech_Press_Button", transform.position); animTop.SetTrigger("pressingButton"); hits[i].transform.GetComponent<InteractiveButton>().Hit(); isPressing = true; } } } } else { if (holding != null) { GetComponent<Weight>().RemoveWeight(holding.gameObject.GetComponent<Weight>().GetWeight()); holding.OnPutDown(); holding = null; animTop.SetBool("pickingUp", false); SoundController.Instance.PlayFX("Mech_Release", transform.position); } isPressing = false; } }