Ejemplo n.º 1
0
        private void DropHeldWeapon()
        {
            Vector3    launchForce   = transform.forward * itemDropForce;
            GameObject droppedWeapon = rightHand.GetComponentInChildren <BaseWeapon>().gameObject;

            if (!droppedWeapon)
            {
                return;
            }

            GameObject newWorldItem = WorldItem.CreateWorldItem(transform.position, transform.rotation, droppedWeapon, launchForce);

            interactor.DroppedObject(newWorldItem);
        }
Ejemplo n.º 2
0
        // Create a new world item based and add our child item to it
        public static GameObject CreateWorldItem(Vector3 position, Quaternion rotation, GameObject itemObject, Vector3 force)
        {
            if (staticWorldItemPrefab == null)
            {
                staticWorldItemPrefab = Resources.Load <GameObject>("Prefabs/WorldItem");
            }

            WorldItem newWorldItem = Instantiate(staticWorldItemPrefab, position, rotation).GetComponent <WorldItem>();

            itemObject.transform.parent        = newWorldItem.transform;
            itemObject.transform.localPosition = Vector3.zero;
            itemObject.transform.localRotation = Quaternion.identity;

            newWorldItem.childObject = itemObject;

            newWorldItem.GetComponent <Rigidbody>().AddForce(force);

            return(newWorldItem.gameObject);
        }