public void OnEdgeCollisionExit(Collider collider, ColliderListenerAction listener) { if (!isGrabbed) { return; } if (!objectsChopping.Contains(collider.gameObject)) { return; } objectsChopping.Remove(collider.gameObject); UpdateColliders(); //inform food item that chopping has ended var foodListener = collider.gameObject.GetComponent <ChoppableFoodObject>(); foodListener.OnEndChop(this); //check chop velocity if (listener.CurrentVelocity.magnitude < MIN_EXIT_VELOCITY) { return; } //send chopped event foodListener.OnChopped(this); //play chop audio audioData.Play(0); }
public void OnEdgeCollisionEnter(Collider collider, ColliderListenerAction listener) { if (!isGrabbed) { return; } //print("Collided with " + collider.gameObject.name + " at " + listener.CurrentVelocity.magnitude); if (listener.CurrentVelocity.y >= 0) { return; // ensure that we are cutting down } if (listener.CurrentVelocity.magnitude < MIN_ENTRANCE_VELOCITY) { return; } //ensure item is choppable var foodListener = collider.gameObject.GetComponent <ChoppableFoodObject>(); if (!foodListener) { return; } //update collision and state objectsChopping.Add(collider.gameObject); UpdateColliders(); //inform food item that chopping has begun foodListener.OnStartChop(this); }
public void OnEdgeCollisionFrame(Collider collider, ColliderListenerAction listener) { }