/// <summary> /// Compares the position and rotation of a part with this slot /// If they are close enough together, and close enough in terms of matching rotation /// Then if they are held in that position for long enough /// We can mark the slot as filled / complete /// </summary> /// <param name="part">The part that we are performing our comparison with</param> private void PerformComparison(InteractionItem part) { Transform other = part.transform; Debug.Log(Vector3.Dot(other.forward, transform.forward)); // If the alignment isnt correct if (((Vector3.Distance(other.position, transform.position) > maxDistance) || ((up) && 1.0f - (upSymmetrical ? Mathf.Abs(Vector3.Dot(other.up, transform.up)) : Vector3.Dot(other.up, transform.up)) > tolerance)) || ((right) && 1.0f - (rightSymmetrical ? Mathf.Abs(Vector3.Dot(other.right, transform.right)) : Vector3.Dot(other.right, transform.right)) > tolerance) || ((forward) && 1.0f - (forwardSymmetrical ? Mathf.Abs(Vector3.Dot(other.forward, transform.forward)) : Vector3.Dot(other.forward, transform.forward)) > tolerance)) { if (progressResets) { currentTimeToComplete = 0.0f; } return; } if (currentTimeToComplete >= timeToComplete) { Complete = true; part.Consume(transform); } currentTimeToComplete += Time.deltaTime; }
/// <summary> /// When anything moves out of the trigger for this slot, we need to remove it from our collection of InteractionItems that we maintain /// </summary> /// <param name="other">The Collider that was intersecting this slot</param> protected void OnTriggerExit(Collider other) { InteractionItem part = other.gameObject.GetComponentInParent <InteractionItem>(); if (part && part.Type == partType) { trackedParts.Remove(part); } }