Exemple #1
0
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("We got a collision!");
        // Because this is a trigger collision, it means other.gameObject is the
        // grab-able rune
        if (active)
        {
            return;                 //if we are already active, return
        }
        Rune otherRune;

        switch (type)
        {
        case runeType.LargeFixed:
            //only care if other is LargeGrab
            otherRune = other.gameObject.GetComponent <Rune>();
            if (otherRune.type == runeType.LargeGrab)
            {
                // Delete other and active this
                henge.Activate(gameObject);
                Destroy(other.gameObject);
            }
            break;

        case runeType.SmallFixed:
            //only care if other is SmallGrab
            otherRune = other.gameObject.GetComponent <Rune>();
            if (otherRune.type == runeType.SmallGrab)
            {
                // Delete other and active this
                henge.Activate(gameObject);
                //drop the item if it was being dragged
                Grappler left  = GameObject.Find("Controller (left)").GetComponent <Grappler>();
                Grappler right = GameObject.Find("Controller (right)").GetComponent <Grappler>();
                if (right.CheckObject(other.gameObject))
                {
                    right.ReleaseObject();
                }
                if (left.CheckObject(other.gameObject))
                {
                    left.ReleaseObject();
                }
                Destroy(other.gameObject);
            }
            break;
        }
    }
Exemple #2
0
 // Start is called before the first frame update
 protected virtual void Start()
 {
     parentHand    = GetComponentInParent <Hand>();
     otherGrappler = parentHand.otherHand.GetComponentInChildren <Grappler>();
 }
Exemple #3
0
 void Awake()
 {
     grappler = GetComponent <Grappler>();
 }