Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool _indexColliding = false;
- private bool _thumbColliding = false;
- void OnCollisionEnter(Collision other) {
- // keep track of the colliding objects
- if (other.gameObject.tag == "index")
- _indexColliding = true;
- else if (other.gameObject.tag == "thumb")
- _thumbColliding = true;
- if (_indexColliding && _thumbColliding) {
- // do something like attaching the object to the fingers
- // or destroy the gameObject
- }
- }
- void OnCollisionExit(Collision other) {
- // reset the booleans if the objects are no longer colliding
- if (other.gameObject.tag == "index")
- _indexColliding = false;
- else if (other.gameObject.tag == "thumb")
- _thumbColliding = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement