예제 #1
0
        /// <summary>
        /// Throw the given item.
        /// </summary>
        /// <param name="carriable">The item to throw.</param>
        public void Throw(Carriable carriable)
        {
            var guide = player.GetComponentInChildren <ThrowingGuide>(true);

            if (guide.ThrowingStrength < 0.33f)
            {
                Drop(carriable);
                return;
            }


            carriable.OnThrow();

            Vector3 playerHead = new Vector3(player.transform.position.x, player.transform.position.y + player.Collider.bounds.size.y);
            Vector3 direction  = (player.GetMouseWorldPosition() - playerHead);

            direction.z = 0;
            direction   = direction.normalized;

            carriable.Physics.Velocity = direction * settings.ThrowingForce * guide.ThrowingStrength;

            // Check if object will collide w/ player. If it does, transport it through
            // character.
            if (direction.y < 0)
            {
                NudgeThrow(carriable, direction);
            }
        }