private void OnTriggerStay(Collider other) { if (!_isFire1Pressed) { return; } IGrabable grabable = other.GetComponentInParent <IGrabable>(); if (grabable != null) { anim.SetBool("Grabbing", true); grabable.GetTransform().SetParent(grabedTransform); Rigidbody rb = grabable.GetTransform().GetComponent <Rigidbody>(); rb.useGravity = false; rb.isKinematic = true; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.transform.localPosition = Vector3.zero; rb.transform.localRotation = Quaternion.Euler(Vector3.zero); grabable.IsGrabbed = true; _grabbing = true; _itemsGrabbed.Add(grabable); _isFire1Pressed = false; } }
public void GrabFlag(IGrabable flag) { if (flag.GetTeam() == teamType) { return; } if ((flag.GetTransform().position - transform.position).magnitude > minFlagRange) { return; } if (flag.Grabbed()) { return; } flag.GetTransform().SetParent(flagHolder); flag.GetTransform().localPosition = Vector3.zero; flag.GetTransform().localRotation = Quaternion.identity; flag.SetGrabbed(true); flag.GetTransform().GetComponent <BoxCollider>().enabled = false; flagTransform = flag.GetTransform(); }