What do you want to save?
Add Code snippet
New code examples
-
Other 2022-01-30 11:30:22
Raycasting to find mouseclick on Object in unity 2d games
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if(hit.collider != null) { Debug.Log ("Target Position: " + hit.collider.gameObject.transform.position); } Add solution -
Other 2022-01-23 03:15:57
get transform from raycast array
//you sould be able to get away with something like this: RaycastHit2D hit = Physics2D.CircleCastAll(currentSoldier.transform.position, currentSoldier.weapon.range, new Vector3(0, 0, 0), 0f); transform transform = hit.transform; Add solution -
C# 2021-11-13 18:55:18
unity spherecast
void CheckSpherecast(float radius, float detectableDistance, LayerMask detectableLayer) { Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.SphereCast(ray, radius, out hitInfo, detectableDistance, detectable... Add solution -
-
Other 2021-11-09 23:49:07
3d mouse raycast object hit name
if ( Input.GetMouseButtonDown (0)){ RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if ( Physics.Raycast (ray,out hit,100.0f)) { StartCoroutine(ScaleMe(hit.transform)); Debug.Log("You selected the &q... Add solution -