UnityEngine.Physics2D.LinecastAll(UnityEngine.Vector2, UnityEngine.Vector2)

Here are the examples of the csharp api UnityEngine.Physics2D.LinecastAll(UnityEngine.Vector2, UnityEngine.Vector2) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 View Source File : Physics2DCast.cs
License : GNU General Public License v3.0
Project Creator : thiagosoara

public override void OnEnter()
        {
            var col = collection.Value;

            if (col != null)
            {
                RaycastHit2D[] rereplaced = null;

                switch (castType)
                {
                    case CastType.Box:
                        rereplaced = Physics2D.BoxCastAll(position1.Value, shapeSize.Value, shapeAngle.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
                        break;

                    case CastType.Capsule:
                        rereplaced = Physics2D.CapsuleCastAll(position1.Value, shapeSize.Value, capsuleDirection, shapeAngle.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
                        break;

                    case CastType.Circle:
                        rereplaced = Physics2D.CircleCastAll(position1.Value, radius.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
                        break;

                    case CastType.Line:
                        rereplaced = Physics2D.LinecastAll(position1.Value, lineEnd.Value, layerMask.value, minDepth.Value, maxDepth.Value);
                        break;

                    case CastType.Ray:
                        rereplaced = Physics2D.RaycastAll(position1.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
                        break;

                    default:
                    break;
                }

                PutCollidersIntoGameObjectCollection(rereplaced);
            }

            Continue();
        }

19 View Source File : DrawLine.cs
License : MIT License
Project Creator : XINCGer

void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            draw = true;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            draw = false;
        }

        if (draw)
        {
            //  line.enabled = true;
            Vector3 dir = Camera.main.ScreenToWorldPoint(Input.mousePosition) - Vector3.back * 10;
       //     if( dir.y - 2 < transform.position.y ) { HidePoints(); return; }
            Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition );
            if( !MainScript.StopControl )
            {//dir.y < 15.5 && dir.y > - 2 && 

                dir.z = 0;
                if (lastMousePos == dir)
                {
                    startAnim = true;
                }
                else startAnim = false;
                lastMousePos = dir;
                line.SetPosition(0, transform.position);

                waypoints[0] = transform.position;
                //int layerMask = ~(1 << LayerMask.NameToLayer("Mesh"));


                RaycastHit2D[] hit = Physics2D.LinecastAll( waypoints[0], waypoints[0] + ( (Vector2)dir - waypoints[0] ).normalized * 10 );
                foreach (RaycastHit2D item in hit)
                {
                    Vector2 point = item.point;
                //    if (point.y - waypoints[0].y < 1.5f) point += Vector2.up * 5;
                    line.SetPosition(1, point);
                    addAngle = 180;

                       if (waypoints[1].x < 0) addAngle = 0;
                       if( item.collider.gameObject.layer == LayerMask.NameToLayer( "Border" ) && item.collider.gameObject.name != "GameOverBorder" && item.collider.gameObject.name != "borderForRoundedLevels" )
                        {
                           Debug.DrawLine( waypoints[0], waypoints[1], Color.red );  //waypoints[0] + ( (Vector2)dir - waypoints[0] ).normalized * 10
                           Debug.DrawLine( waypoints[0], dir, Color.blue );
                           Debug.DrawRay( waypoints[0], waypoints[1] - waypoints[0], Color.green );
                           waypoints[1] = point;
                           waypoints[2] = point;
                           line.SetPosition( 1, dir );
                            waypoints[1] = point;
                            float angle = 0;
                            angle = Vector2.Angle(waypoints[0] - waypoints[1], (point - Vector2.up * 100) - (Vector2)point);
                            if (waypoints[1].x > 0) angle = Vector2.Angle(waypoints[0] - waypoints[1], (Vector2)point - (point - Vector2.up * 100));
                            waypoints[2] = Quaternion.AngleAxis(angle + addAngle, Vector3.back) * ((Vector2)point - (point - Vector2.up * 100));
                            Vector2 AB = waypoints[2] - waypoints[1];
                            AB = AB.normalized;
                            line.SetPosition(2, waypoints[2]);
                            break;
                        }
                        else if (item.collider.gameObject.layer == LayerMask.NameToLayer("Ball"))
                        {
                            Debug.DrawLine( waypoints[0], waypoints[1], Color.red );  //waypoints[0] + ( (Vector2)dir - waypoints[0] ).normalized * 10
                            Debug.DrawLine( waypoints[0], dir, Color.blue );
                            Debug.DrawRay( waypoints[0], waypoints[1] - waypoints[0], Color.green );
                            line.SetPosition( 1, point );
                            waypoints[1] = point;
                            waypoints[2] = point;
                            Vector2 AB = waypoints[2] - waypoints[1];
                            AB = AB.normalized;
                            line.SetPosition(2, waypoints[1] + (0.1f * AB));
                            break;
                        }
                        else
                        {

                            waypoints[1] = waypoints[0] + ( (Vector2)dir - waypoints[0] ).normalized * 10;
                            waypoints[2] = waypoints[0] + ( (Vector2)dir - waypoints[0] ).normalized * 10;
                        }

                    
 
                }
                if (!startAnim )
                    GeneratePositionsPoints();

            }

        }
        else if (!draw)
        {
            HidePoints();
        }

    }