unity 2d detect click on sprite
C#
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);
}
Also in C#:
- Title
- modal dismiss
- Category
- C#
- Title
- c# round number down
- Category
- C#
- Title
- c# making a folder
- Category
- C#
- Title
- how to move towards an object unity
- Category
- C#
- Title
- mysql executeScalar only if successful
- Category
- C#
- Title
- c# generate random number
- Category
- C#
- Title
- convert from xls to xlsx C#
- Category
- C#
- Title
- generate a dropdown list from array data using razor .net mvc
- Category
- C#
- Title
- c# how to exit program
- Category
- C#
- Title
- c# mixed multidimensional array
- Category
- C#
- Title
- c# bool list count true
- Category
- C#
- Title
- F# convert generic.List to list
- Category
- C#
- Title
- linq in c#
- Category
- C#
- Title
- console application in c# ms crm
- Category
- C#
- Title
- exit game unity
- Category
- C#
- Title
- to list c#
- Category
- C#
- Title
- c# combobox datasource enum
- Category
- C#
- Title
- covert char[] to string C#
- Category
- C#
- Title
- when do i need to end a sentence with ; in c#
- Category
- C#
- Title
- csharp first element of array
- Category
- C#
- Title
- c# convert list to string
- Category
- C#
- Title
- get random point within radius
- Category
- C#
- Title
- loop over enum values
- Category
- C#
- Title
- c# find index element array
- Category
- C#
- Title
- unity variable from another script
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- landscape print gridcontrol devexpress
- Category
- C#
- Title
- vb.net drag window without titlebar
- Category
- C#
- Title
- how do i foreach c#
- Category
- C#
- Title
- application variable in asp.net core
- Category
- C#
- Title
- unity get max occurrence in list
- Category
- C#
- Title
- c# cheat sheet
- Category
- C#
- Title
- how to find object by ag unity
- Category
- C#
- Title
- set object to random color unity
- Category
- C#
- Title
- c sharp substring
- Category
- C#
- Title
- unity hide mouse
- Category
- C#
- Title
- loop gridcontrol devexpress c#
- Category
- C#
- Title
- set width of rect transform unity
- Category
- C#
- Title
- c# string remove special characters
- Category
- C#
- Title
- find negative version of integer in c#
- Category
- C#
- Title
- unity how to change the text on a button
- Category
- C#
- Title
- validating file upload asp.net core mvc
- Category
- C#
- Title
- how to start an if statement in c#
- Category
- C#
- Title
- C# array to string
- Category
- C#
- Title
- unity remove parent
- Category
- C#
- Title
- C# previous method
- Category
- C#
- Title
- how to add a componet to a gameobject throgh code unity
- Category
- C#
- Title
- c# set textbox text
- Category
- C#
- Title
- how get data from json in c#
- Category
- C#
- Title
- override Microsoft.AspNetCore.Authorization.AuthorizeAttribute
- Category
- C#
- Title
- how to reference the position of a game object unity
- Category
- C#
- Title
- how to make a pause feautre in unity
- Category
- C#
- Title
- isdaylightsavingtime in c#
- Category
- C#
- Title
- csharp attributes as generics constraints
- Category
- C#
- Title
- remove all array elements c#
- Category
- C#
- Title
- c# join string array
- Category
- C#
- Title
- how consider the first caracter in Split c#
- Category
- C#
- Title
- c# access session in class
- Category
- C#
- Title
- where keyword in c#
- Category
- C#
- Title
- abstract class c#
- Category
- C#
- Title
- c sharp list indexer
- Category
- C#
- Title
- mvc c# w3schools
- Category
- C#
- Title
- unity simple fps controller
- Category
- C#
- Title
- c# how to run external program with args
- Category
- C#
- Title
- how to create a variable in C#
- Category
- C#
- Title
- convert string to boolean c#
- Category
- C#
- Title
- c# get desktop path
- Category
- C#
- Title
- unity making homing missile
- Category
- C#
- Title
- c# request run as administrator
- Category
- C#
- Title
- c# function return
- Category
- C#
- Title
- unity how to change rotation
- Category
- C#
- Title
- unity set sprite transparency
- Category
- C#
- Title
- object escape player unity
- Category
- C#
- Title
- c# replace foreach with lambda
- Category
- C#
- Title
- dto and automapper
- Category
- C#
- Title
- convert generic to type c#
- Category
- C#
- Title
- c# empty IEnumerable
- Category
- C#
- Title
- unity how to check object position
- Category
- C#
- Title
- c# creating a data recovery software
- Category
- C#
- Title
- page parent wpf
- Category
- C#
- Title
- how to add a list to observablecollection in c#
- Category
- C#
- Title
- change z value unity
- Category
- C#
- Title
- c# get full URL of page
- Category
- C#
- Title
- c# get enum in list
- Category
- C#
- Title
- disable a component unity
- Category
- C#
- Title
- define enum c#
- Category
- C#
- Title
- c# random number between 0 and 1
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- unity how to tell when a gameobject is colliding
- Category
- C#
- Title
- can send but cannot receive email dreamhost email
- Category
- C#
- Title
- unity move character
- Category
- C#
- Title
- add mime type for woff in web.config
- Category
- C#
- Title
- c# Sleep
- Category
- C#
- Title
- Unity how to put IEnumerator in update and loop once with yeild return new waitforseconds
- Category
- C#
- Title
- unity custom update
- Category
- C#
- Title
- how to sort string array alphabetically in c#
- Category
- C#
- Title
- c# how to add newline on text box
- Category
- C#
- Title
- c# groupby date
- Category
- C#
- Title
- text variable type unity
- Category
- C#