UnityEngine.Physics2D.Raycast(UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.ContactFilter2D, UnityEngine.RaycastHit2D[], float)

Here are the examples of the csharp api UnityEngine.Physics2D.Raycast(UnityEngine.Vector2, UnityEngine.Vector2, UnityEngine.ContactFilter2D, UnityEngine.RaycastHit2D[], float) 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 : snakeObstacle.cs
License : MIT License
Project Creator : Crazy-Marvin

public void applyDamage()
    {
        if (!affectedPlayer)
        {
            RaycastHit2D hitFront = Physics2D.Raycast(rayCastPoint.transform.position, -Vector2.right * (float)0.3, LayerMask.NameToLayer("Player"));
            RaycastHit2D hitUp = Physics2D.Raycast(rayCastPoint.transform.position, Vector2.up * (float)0.3, LayerMask.NameToLayer("Player"));
            if (hitFront)
            {
                if (hitFront.collider.gameObject.tag == "Player")
                {
                    hitFront.collider.gameObject.GetComponent<PlayerController>().changeHealth(healthEffect);

                    affectedPlayer = true;
                    Destroy(this.gameObject, (float)1);
                }

            }
            else if(hitUp)
            {
                if (hitUp.collider.gameObject.tag == "Player")
                {
                    hitUp.collider.gameObject.GetComponent<PlayerController>().changeHealth(healthEffect);

                    affectedPlayer = true;
                    Debug.Log("damaged");
                    Destroy(this.gameObject, (float)1);
                }

            }


        }   
    }

19 View Source File : CowboyObstacle.cs
License : MIT License
Project Creator : Crazy-Marvin

void FixedUpdate()
    {
        hit = Physics2D.Raycast(rayCastPos.position, -Vector2.right, layerMask);
        if (hit.collider != null)
        {
            // Calculate the distance from the surface and the "error" relative
            // to the floating height.
            float distance = Mathf.Abs(hit.point.x - transform.position.x);
            Debug.Log(hit.transform.name);


           // RB.AddForce(Vector3.up * force);
        }
    }