Beispiel #1
0
        /// <summary>
        /// check if there is wall in front of character
        /// </summary>
        /// <param name="character">character interacting with trigger</param>
        /// <param name="limbIK">ik helper class</param>
        /// <param name="inpos">input position</param>
        /// <param name="target">target transform</param>
        /// <param name="moveright">move right or left</param>
        /// <returns>returns true if wall is in front otherwise false</returns>
        private bool _checkIsWallUnderTarget(TPCharacter character, IKHelper limbIK, Vector3 inpos, Transform target, bool moveright = true)
        {
            Vector3 offset = new Vector3(0.0f, character.capsule.height * 0.5f, 0.25f);

            offset = target.rotation * offset;
            Vector3 pos         = inpos - offset;
            float   ledgeLength = (character.ledge.rightPoint - character.ledge.leftPoint).magnitude;
            Vector3 ledgeDir    = character.getLedgeDirection();
            float   dirOffset   = Mathf.Min(ledgeLength, character.capsule.radius);

            if (moveright)
            {
                pos -= ledgeDir * dirOffset;
            }
            else
            {
                pos += ledgeDir * dirOffset;
            }
            Ray        ray = new Ray(pos, target.forward);
            RaycastHit hit;
            int        mask   = character.layers;
            float      radius = character.capsule.radius * 0.38f;
            float      dist   = limbIK.hangCheckDistance + 0.25f;

            if (Physics.SphereCast(ray, radius, out hit, dist, mask))
            {
                return(true);
            }
            return(false);
        }