OverlapPoint() public method

Check if a collider overlaps a point in space.

public OverlapPoint ( Vector2 point ) : bool
point Vector2 A point in world space.
return bool
示例#1
0
    void OnTriggerStay2D(Collider2D col)
    {
        ///get position of click
        clickPosition.x = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
        clickPosition.y = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
        ///currently, click must be on player
        if (col.tag == "Player" && ((Input.GetKeyDown(KeyCode.Space)) || (col.OverlapPoint(clickPosition) && Input.GetMouseButtonDown(0))))
        {

            if (exit != null)
            {
                cameraScript.follow = false;
                cameraScript.target = exit.transform;

            }
            else
            {
                Debug.Log("no exit assigned");
            }

            Debug.Log("Teleport Complete!"); // confirm that teleport is complete; this can be taken out
            TeleportToExit2D(col);

        }
        /*
        else
        {
            //cameraScript.follow = true;//allows smooth transition for each teleport
        }
        */
    }
 static public int OverlapPoint(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Collider2D self = (UnityEngine.Collider2D)checkSelf(l);
         UnityEngine.Vector2    a1;
         checkType(l, 2, out a1);
         var ret = self.OverlapPoint(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
示例#3
0
    void OnTriggerStay2D( Collider2D col)
    {
        ///get position of click
        clickPosition.x = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
        clickPosition.y = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
        ///currently, click must be on player
        if (col.tag == "Player" && ((Input.GetKeyDown(KeyCode.Space))||(col.OverlapPoint(clickPosition) && Input.GetMouseButtonDown(0))))
        {

                Debug.Log("Teleport Complete!"); // confirm that teleport is complete; this can be taken out
                TeleportToExit2D(col);

        }
    }
	static public int OverlapPoint(IntPtr l) {
		try {
			UnityEngine.Collider2D self=(UnityEngine.Collider2D)checkSelf(l);
			UnityEngine.Vector2 a1;
			checkType(l,2,out a1);
			var ret=self.OverlapPoint(a1);
			pushValue(l,true);
			pushValue(l,ret);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 static public int OverlapPoint(IntPtr l)
 {
     try{
         UnityEngine.Collider2D self = (UnityEngine.Collider2D)checkSelf(l);
         UnityEngine.Vector2    a1;
         checkType(l, 2, out a1);
         System.Boolean ret = self.OverlapPoint(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
示例#6
0
 static int QPYX_OverlapPoint_YXQP(IntPtr L_YXQP)
 {
     try
     {
         ToLua.CheckArgsCount(L_YXQP, 2);
         UnityEngine.Collider2D QPYX_obj_YXQP  = (UnityEngine.Collider2D)ToLua.CheckObject <UnityEngine.Collider2D>(L_YXQP, 1);
         UnityEngine.Vector2    QPYX_arg0_YXQP = ToLua.ToVector2(L_YXQP, 2);
         bool QPYX_o_YXQP = QPYX_obj_YXQP.OverlapPoint(QPYX_arg0_YXQP);
         LuaDLL.lua_pushboolean(L_YXQP, QPYX_o_YXQP);
         return(1);
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
 static int OverlapPoint(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Collider2D obj  = (UnityEngine.Collider2D)ToLua.CheckObject(L, 1, typeof(UnityEngine.Collider2D));
         UnityEngine.Vector2    arg0 = ToLua.ToVector2(L, 2);
         bool o = obj.OverlapPoint(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#8
0
    //allows actions when staying within collision area
    void OnTriggerStay2D(Collider2D col)
    {
        // OverlapPoint refers to world space instead of screen space, adjusting accordingly
        clickPosition.x = (Camera.main.ScreenToWorldPoint(Input.mousePosition).x);
        clickPosition.y = (Camera.main.ScreenToWorldPoint(Input.mousePosition).y);

        //Toggle Hide/Unhide
        if ((Input.GetKeyDown(KeyCode.Space) || (Input.GetMouseButtonDown(0) && col.OverlapPoint(clickPosition)))) //if player activates hiding spot
            //|| ((hide && ((Input.GetAxis("Horizontal") > 0.9)||(Input.GetAxis("Horizontal") < -0.9)))  //or if player is hidden and moves using the keyboard
            //|| (hide && Input.GetMouseButton(0)&& (Input.mousePosition.x < edgeLeft.x || Input.mousePosition.x > edgeRight.x)))) //or if player is hidden and moves using the mouse
        {
            if (col.gameObject.tag == "Cover")
            {
                if (!hide)
                {
                    sprite.sortingOrder = hidingOrder;
                    hide = true;
                }
                else if (hide)
                {
                    sprite.sortingOrder = sortingOrder;
                    hide = false;

                    if (slowMo) //Disables slowmotion speed upon hiding
                    {
                        slowMo = false;
                    }
                }
            }
            //if player is trying to hide, and the object is the trap enemy
            else if (col.gameObject.tag == "Enemy")
            {
                //player dies
                isAlive = false;
                //prevents movement
                normalSpeed = 0f;
            }

          }

        //if player colliders with an enemy and is not hidden
        if (col.gameObject.tag == "PatrolEnemy" && hide == false)
        {
            //player is dead
            isAlive = false;
            //prevent player from moving
            normalSpeed = 0f;
        }
           ///gameover for stationary enemies handled in their own code
    }
示例#9
0
    //allows actions when staying within collision area
    void OnTriggerStay2D(Collider2D col)
    {
        // OverlapPoint refers to world space instead of screen space, adjusting accordingly
        clickPosition.x = (Camera.main.ScreenToWorldPoint(Input.mousePosition).x);
        clickPosition.y = (Camera.main.ScreenToWorldPoint(Input.mousePosition).y);

        //Toggle Hide/Unhide
        if ((Input.GetKeyDown(KeyCode.Space) || (Input.GetMouseButtonDown(0)&& col.OverlapPoint(clickPosition))))
        {
            if (col.gameObject.tag == "Cover")
            {
                if (!hide)
                {
                    sprite.sortingOrder = hidingOrder;
                    hide = true;
                }
                else if (hide)
                {
                    sprite.sortingOrder = sortingOrder;
                    hide = false;

                    if (slowMo) //Disables slowmotion speed upon hiding
                    {
                        slowMo = false;
                    }
                }
            }

          }

        //if player colliders with an enemy and is not hidden
        if (col.gameObject.tag == "PatrolEnemy" && hide == false)
        {
            //player is dead
            isAlive = false;
            //prevent player from moving
            normalSpeed = 0f;
        }
           ///gameover for stationary enemies handled in their own code
    }
示例#10
-1
文件: Floor.cs 项目: Syjgin/zerotram
 private bool IsHeroNearWayout(Collider2D wayout, bool central)
 {
     if (_hero == null)
         return false;
     Vector2 position = _hero.transform.position;
     if (central)
         position.y -= 0.7f;
     Vector3 position2check = new Vector3(position.x, position.y, wayout.transform.position.z);
     return wayout.OverlapPoint(position2check);
 }