Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity 2d raycast mouse

// detect object that was clicked using raycast

RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
 
if(hit.collider != null)
{
    Debug.Log ("Target name: " + hit.collider.name);
}
Comment

unity raycast 2d

Physics2D.Raycast(Vector2 origin, Vector2 direction, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, float minDepth = -Mathf.Infinity, float maxDepth = Mathf.Infinity);
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity to integer 
Csharp :: c# how-to-download-image-from-url 
Csharp :: c# player movement 
Csharp :: check if process is open c# 
Csharp :: unity set object scale 
Csharp :: how to get delta time in monogame 
Csharp :: Change fog setting Unity 
Csharp :: how to change the color of your text in c# 
Csharp :: Animator.GotoState: State could not be found UnityEngine.Animator:Play (string) 
Csharp :: c# foreach enum 
Csharp :: how to do a foreach loop in c# for dictionary 
Csharp :: spawn a object with unity 
Csharp :: unity color set alpha 
Csharp :: c# random boolean 
Csharp :: c# string to double 
Csharp :: unity save list to json 
Csharp :: query parameter c# controller 
Csharp :: get random point in collider unity 
Csharp :: c# prime factorization 
Csharp :: how to detect when a player move in unity 
Csharp :: c# press key 
Csharp :: sort a dictionary by value in c# 
Csharp :: system.text.json DeserializeAsync when to use 
Csharp :: wpf set image source in code behind 
Csharp :: c# windows application get current path 
Csharp :: minheap c# 
Csharp :: unity system time 
Csharp :: how to get the time since play unity 
Csharp :: override indexation C# 
Csharp :: how to show a reference in unity 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =