public void ToTheGround() { FindObjectOfType <AudioManager>().Stop("forceField"); grabScript.DeactivateParticles(); forceParticles.SetFloat("Input", 0f); ArmsAnimatorBehabior.GrabObjects(0); rigidBody.isKinematic = false; grabScript.grabbingAnObject = false; transform.parent = null; GetComponent <BoxCollider>().isTrigger = false; }
void Update() { if (Input.GetButtonDown("GrabObject") && !grabbingAnObject) { RaycastHit hit; if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.TransformDirection(Vector3.forward), out hit, minDistance, layer)) { grabbingAnObject = true; objectToGrab = hit.transform.gameObject; objectToGrab.GetComponent <GrabbableObject>().ActivateVFX(); objectToGrab.GetComponent <Rigidbody>().useGravity = false; StartCoroutine("IsTrigger"); objectToGrab.transform.parent = Camera.main.transform; ArmsAnimatorBehabior.GrabObjects(1); FindObjectOfType <AudioManager>().Play("forceField"); } } if (grabbingAnObject) { //print("cargando objeto"); if (Input.GetButtonDown("ThrowObject")) //click alt -> lanzar { FindObjectOfType <AudioManager>().Play("throwObject"); ArmsAnimatorBehabior.GrabObjects(2); DeactivateParticles(); } else if (Input.GetButtonUp("GrabObject")) { //print("soltar"); ArmsAnimatorBehabior.GrabObjects(0); objectToGrab.GetComponent <GrabbableObject>().ToTheGround(); DeactivateParticles(); } } }