Пример #1
0
        /// <summary>
        /// 从玩家手上到预定drop点连线,判断中间是否有物体阻挡
        /// </summary>
        /// <param name="playerEntity"></param>
        /// <param name="hitInfo"></param>
        /// <param name="specifiedRaycast"></param>
        /// <returns></returns>
        public static bool RaycastPlayerDropObject(PlayerEntity playerEntity, Vector3?dropPos, out RaycastHit hitInfo, RaycastDel specifiedRaycast = null)
        {
            specifiedRaycast = specifiedRaycast ?? defaultRaycast;
            var handPosVal = SceneObjectPositionUtil.GetHandObjectPosition(playerEntity);
            var dropPosVal = dropPos.HasValue?dropPos.Value: SceneObjectPositionUtil.GetPlayerDropPos(playerEntity);

            return(specifiedRaycast(handPosVal, dropPosVal - handPosVal, out hitInfo, Vector3.Distance(handPosVal, dropPosVal),
                                    dropLayer));
        }
Пример #2
0
        public static Vector3 GetDropObjectPos(PlayerEntity playerEntity, RaycastDel specifiedRaycast = null)
        {
            var dropPos = SceneObjectPositionUtil.GetPlayerDropPos(playerEntity);

            RaycastHit hitInfo;

            if (RaycastPlayerDropObject(playerEntity, dropPos, out hitInfo, specifiedRaycast))
            {
                dropPos = GetFixedDropPos(hitInfo.point, specifiedRaycast);
            }
            else
            {
                dropPos = GetFixedDropPos(dropPos, specifiedRaycast);
            }

            return(dropPos);
        }