Ejemplo n.º 1
0
        public static Vector3 PointInsideCircle(Vector3 center, float radius, LayerMask groundLayerMask)
        {
            Vector2 new2dPos = Random.insideUnitCircle * radius;
            Vector3 new3dPos = center + new Vector3(new2dPos.x, 0, new2dPos.y);

            return(PhysicsUtils.RaycastFromUpToDown(new3dPos, groundLayerMask).point);
        }
Ejemplo n.º 2
0
 private void OnDrawGizmos()
 {
     if (!_isDoneRaycastToGround)
     {
         transform.position     = PhysicsUtils.RaycastFromUpToDown(transform.position, Consts.LayerMasks.GroundForUnits).point + new Vector3(0, _positionAboveGround, 0);
         _isDoneRaycastToGround = true;
     }
 }
Ejemplo n.º 3
0
 private void OnDrawGizmos()
 {
     if (!_isDoneRaycastToGround)
     {
         //после остановки игры в редакторе, или при запуске редактора, устанавливает Y позицию в точке, где земля.
         transform.position     = PhysicsUtils.RaycastFromUpToDown(transform.position, Consts.LayerMasks.GroundForUnits).point;
         _isDoneRaycastToGround = true;
     }
 }
Ejemplo n.º 4
0
    private IEnumerator MoveCoroutine()
    {
        while (transform.position.y > _targetYpos)
        {
            transform.Translate(-Vector3.up * _speed * Time.deltaTime);
            yield return(new WaitForEndOfFrame());
        }

        transform.position = PhysicsUtils.RaycastFromUpToDown(transform.position, Consts.LayerMasks.BallCollisions).point;
        Explosion();
    }
Ejemplo n.º 5
0
    private void UpdatePositionAboveGround()
    {
        RaycastHit hit = PhysicsUtils.RaycastFromUpToDown(_newPos, Consts.LayerMasks.GroundForCamera);

        if (hit.collider != null)
        {
            var height = PhysicsUtils.RaycastHeigthFromUpToDown - hit.distance + _positionAboveGround;
            _newPos.y = height;
        }
        else
        {
            Debug.LogWarning("Camera position is not over ground", this);
        }
    }
Ejemplo n.º 6
0
    public static void DrawSquareGrid(Vector3 center, float size, float countCells)
    {
#if UNITY_EDITOR
        Vector3 gridCenter = center + new Vector3(-size / 2f + 0.5f, 0f, -size / 2f + 0.5f);
        for (int i = 0; i < size; i++)
        {
            for (int j = 0; j < size; j++)
            {
                if (countCells <= i * size + j)
                {
                    return;
                }

                var cellCenter = PhysicsUtils.RaycastFromUpToDown(gridCenter + new Vector3(i, 0, j), Consts.LayerMasks.GroundForUnits).point;
                Gizmos.DrawCube(cellCenter, new Vector3(0.9f, 1f, 0.9f));
            }
        }
#endif
    }
Ejemplo n.º 7
0
 private bool CheckGround(Vector3 testPosition)
 {
     return(PhysicsUtils.RaycastFromUpToDown(transform.position, Consts.LayerMasks.GroundForCamera).collider != null);
 }
Ejemplo n.º 8
0
 private bool HasGroundUnderPoint(Vector3 position)
 {
     return(PhysicsUtils.RaycastFromUpToDown(position, Consts.LayerMasks.GroundForCamera).collider != null);
 }