Last active
August 29, 2015 14:18
-
-
Save unitycoder/76645525b612c9d03456 to your computer and use it in GitHub Desktop.
Revisions
-
unitycoder revised this gist
May 14, 2015 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,17 +4,29 @@ public class Test : MonoBehaviour { public LayerMask targetLayer; Vector3 prevPos; void Start () { } void Update () { // to mouse point Ray mousePos = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(mousePos.origin, mousePos.direction,Mathf.Infinity, targetLayer); if (hit.collider != null) { Destroy(hit.transform.gameObject); } // from point to point Vector3 mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y,10)); hit = Physics2D.Linecast(prevPos, mousePos); if (hit.collider != null) { Debug.Log("collided at:"+hit.point); } prevPos = mousePos; } } -
unitycoder renamed this gist
May 11, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
unitycoder created this gist
Apr 7, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ using UnityEngine; using System.Collections; public class Test : MonoBehaviour { public LayerMask targetLayer; void Start () { } void Update () { Ray mousePos = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(mousePos.origin, mousePos.direction,Mathf.Infinity, targetLayer); if (hit.collider != null) { Destroy(hit.transform.gameObject); } } }