Beispiel #1
0
        public void ReleaseMagazine()
        {
            if (magazine != null)
            {
                magazine.OnDrop();
                audioSources[0].clip = magOutSound;
                audioSources[0].Play();

                magazineObj.transform.parent = null;
                magazineObj = null;
                magazine    = null;
            }
        }
Beispiel #2
0
 public void AttachMagazine(GameObject magObj)
 {
     if (magazineObj == null)
     {
         magObj.transform.parent = magazineOffset;
         var rb = magObj.GetComponent <Rigidbody> ();
         rb.velocity = Vector3.zero;
         Destroy(rb);
         magObj.transform.localPosition = Vector3.zero;
         magObj.transform.localRotation = Quaternion.Euler(Vector3.zero);
         magazine             = magObj.GetComponent <Magazine> ();
         audioSources[0].clip = magInSound;
         audioSources[0].Play();
     }
 }
        void OnTriggerEnter(Collider collider)
        {
            //Debug.Log ("Magazine trigger enter found " + collider.gameObject.name);
            if (collider.tag == "Magazine")
            {
                var m = collider.GetComponentInParent <Magazine> ();
                nearbyMagazine = m;

                if (m.itemName == "AK Magazine" && gun.itemName == "Kalashnikov")
                {
                    try {
                        closestControllerEvents = m.GetGrabbingObject().GetComponent <VRTK_ControllerEvents> ();
                        closestControllerEvents.GripReleased += ClosestControllerEvents_GripReleased;
                    } catch {
                        Debug.LogWarning("Potential error in magazine - sometimes occurs when moving and can be ignored.");
                    }
                }
            }
        }