Advertisement
Guest User

Problem with triggers

a guest
Feb 3rd, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1.  
  2. //This is my object drag, might help.. it's a .cs code attached to the game object
  3.     void OnMouseDrag()
  4.     {
  5.         Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
  6.         Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
  7.         if (Global.noGrid[0]) //noGrid means inside the grid ('no' in Portuguese means 'in')
  8.         {
  9.             transform.position = Global.FindClosestObject(curPosition, "gizmo_peca").transform.position; // here i find the game closest gameobject inside the grid, i do that because i need a snap (that's why i need the trigger working to, to recognize which gameobject it's colliding
  10.         }
  11.         else
  12.         {
  13.             transform.position = new Vector3(curPosition.x, curPosition.y, curPosition.z);
  14.         }
  15.        
  16.     }
  17.  
  18. // This is what i tried but with no success in BlockForma.cs (It's how I call my gameobject above)
  19.     void OnTriggerEnter2D(Collider2D c)
  20.     {
  21.  
  22.         if (c.tag == "Forma")
  23.         {
  24.             c.rigidbody2D.velocity = new Vector2(0,0);
  25.             Debug.Log("Hello");
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement