Exemple #1
0
        public void PickUp(PlayerInteractionBehaviour interaction)
        {
            player      = interaction;
            player.item = this;
            var string_type = _I.GetType().ToString();

            player.CmdSetHolding(true, string_type);
            player.CmdSetItemBeingHeld(true, item_network_identity);

            player.CmdAssignItemAuthority(item_network_identity);
            Debug.Log("ATTEMPT TO ASSIGN AUTHORITY: EXPECTED = True, RESULT = " + item_network_identity.hasAuthority.ToString());

            rb.MovePosition(player.HoldingItemPosition.position);

            var colliders = GetComponents <Collider>().ToList();

            colliders.ForEach(collider =>
            {
                if (!collider.isTrigger)
                {
                    collider.enabled = false;
                }
                //collider.enabled = false;
            });
            rb.useGravity = false;
            rb.velocity   = Vector3.zero;
        }
Exemple #2
0
        private void OnisDeadChange(bool Dead)
        {
            isDead = Dead;
            if (isDead)
            {
                var controller = GetComponent <CharacterController>();
                controller.detectCollisions = false;

                colliders.ForEach(collider =>
                {
                    collider.enabled = false;
                });

                var holding_item = interaction.isHolding;
                if (holding_item)
                {
                    if (interaction.item != null)
                    {
                        interaction.item.isBeingHeld = false;
                        interaction.item.CmdSetHolding(false);
                        interaction.DropItem();
                    }

                    //interaction.item.Drop();
                    interaction.CmdSetHolding(false, "");
                    ic.enabled          = false;
                    interaction.enabled = false;
                }

                if (isLocalPlayer)
                {
                    if (isDriving)
                    {
                        if (vehicle != null)
                        {
                            RemovePlayerFromVehicle();
                        }
                    }
                    CmdSpawnRagdoll();
                }
            }
        }
Exemple #3
0
        public void Drop()
        {
            player.CmdRemoveItemAuthority(item_network_identity);
            Debug.Log("ATTEMPT TO REMOVE AUTHORITY: EXPECTED = False, RESULT = " + item_network_identity.hasAuthority.ToString());

            player.CmdSetHolding(false, "");
            player.CmdSetItemBeingHeld(false, item_network_identity);
            isBeingHeld = false;
            player.item = null;

            var colliders    = GetComponents <Collider>().ToList();
            var trigger_size = Vector3.zero;

            colliders.ForEach(collider =>
            {
                if (!collider.isTrigger)
                {
                    collider.enabled = true;
                }
                else
                {
                    collider.enabled = true;
                    trigger_size     = collider.bounds.size;
                    collider.enabled = false;
                }
            });

            rb.isKinematic = false;
            rb.constraints = RigidbodyConstraints.None;
            rb.useGravity  = true;

            var drop_position = Vector3.zero;

            var isUsingItem = player.Ani.GetBool("UsingItem");

            if (isUsingItem)
            {
                //DROP ITEM INFRONT OF PLAYER
                var front_drop_position = trigger_size;
                front_drop_position.x = 0;
                front_drop_position.y = 0;
                front_drop_position.z = front_drop_position.z * DropItemOffset;

                drop_position = player.transform.TransformPoint(front_drop_position);
            }
            else
            {
                //DROP ITEM ON SIDE OF PLAYER
                var side_drop_position = trigger_size;
                side_drop_position.x = side_drop_position.x * DropItemOffset;
                side_drop_position.y = 0;
                side_drop_position.z = 0;

                drop_position = player.transform.TransformPoint(side_drop_position);
            }

            drop_position.y = transform.position.y;

            //var drop_position = player.HoldingItemPosition.position;
            //trigger_size.y = 0;
            //trigger_size.x = 0;
            //trigger_size.z = -trigger_size.z;

            //drop_position += trigger_size * DropItemOffset;

            RaycastHit hit;

            if (Physics.Raycast(transform.position, -Vector3.up, out hit))
            {
                //PUT THE ITEM ON THE GROUND
                drop_position.y -= hit.distance;
            }

            rb.transform.position = (drop_position);
            //rb.MovePosition(drop_position);
            rb.velocity = -Vector3.up * DropItemPower;

            //rb.MovePosition(drop_position);

            player = null; //REMOVE REFRENCE TO PLAYER
        }