IEnumerator PickUp(GameObject obj) { // Look at the object Vector3 direction = obj.transform.position - transform.position; direction = new Vector3(direction.x, transform.position.y, direction.z); transform.forward = direction; look.LooseFocus(); Grabbable grab = obj.GetComponent <Grabbable>(); if (grab != null) { grab.BecomeHeldBy(handBone); } ChangeState(HumanState.Thinking); anim.SetTrigger("Pickup"); yield return(new WaitForSeconds(1f)); if (seenItem != null && seenItem.gameObject != null) { Destroy(seenItem.gameObject); } // Return to normal state ChangeState(HumanState.Walking); if (path.Count > 0) { MoveTo(0); } }
public void GrabObject(Grabbable prop) { if (prop.IsCosmetic()) { Wear(prop); return; } float headHeight = collider.height / 2 + prop.GetComponent <Collider>().bounds.extents.y / 2 + collider.bounds.center.y; prop.BecomeHeldBy(transform, new Vector3(0f, headHeight, 0f)); heldObject = prop; // Visuals sweat.Activate(); anim.SetBool("Carrying", true); SoundPlayer.PlayWithRandomPitch("fb_raccoon_grabbing", 0.5f); }