Beispiel #1
0
    void OnTriggerEnter(Collider coll)
    {
        if (coll.tag == "Player" && player == null)
        {
            Debug.Log("Collided with: " + coll.name);

            Player_Base _player = coll.GetComponent <Player_Base>();
            if (_player != null)
            {
                GunSlot_Base _gunSlot = _player.GunSlot;

                if (_gunSlot != null && _gunSlot.TryPickup(this))
                {
                    player  = _player;
                    gunSlot = _gunSlot;
                    gameObject.transform.parent = _gunSlot.transform;

                    Destroy(GetComponent <Rigidbody>());
                    enabled = true;

                    Collider[] colliders = GetComponents <Collider>();
                    foreach (Collider c in colliders)
                    {
                        c.enabled = false;
                    }

                    transform.localPosition = Vector3.zero;
                    transform.localRotation = Quaternion.Euler(0, 180, 0);
                    AlignGun();
                }
            }
        }
    }
Beispiel #2
0
 public override bool TryPickupGun(Gun_Base gun)
 {
     //TODO: make the pickup gun script target the weapon slot directly
     return(gunSlot.TryPickup(gun));
 }