Horje
unity 2d detect click on sprite Code Example
unity 2d detect click on sprite
if (Input.GetMouseButtonDown(0)) {
            Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);
            
            RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
            if (hit.collider != null) {
                Debug.Log(hit.collider.gameObject.name);
                hit.collider.attachedRigidbody.AddForce(Vector2.up);
            }




Csharp

Related
how to convert angle to vector in c# Code Example how to convert angle to vector in c# Code Example
unity pause animator Code Example unity pause animator Code Example
c# print out Code Example c# print out Code Example
how to delay execution in c# Code Example how to delay execution in c# Code Example
usermanager change password without current password Code Example usermanager change password without current password Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7