Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Point to mouse 2D Unity

Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        difference.Normalize();
        float rotation_z = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.Euler(0f, 0f, rotation_z + offset);
Comment

PREVIOUS NEXT
Code Example
Csharp :: net core get remote ip 
Csharp :: unity how to set gameobjkect enabled 
Csharp :: center an image horizontally and vertically 
Csharp :: c# getasynckeystate mouse 
Csharp :: c# random int 
Csharp :: Vector3.signedangle not showin singed angle in unity 
Csharp :: how to delete all files in a directory c# 
Csharp :: ALWAYS MAximize window on start c# 
Csharp :: C# open a new form 
Csharp :: unity ray from mouse position 
Csharp :: unity play particle system 
Csharp :: movement script c# 
Csharp :: restclient basic auth c# 
Csharp :: Change fog setting Unity 
Csharp :: Program for factorial of a number in c# 
Csharp :: c# for loop backwards 
Csharp :: c# get last character of string 
Csharp :: c# convert Unix time in seconds to datetime 
Csharp :: how to make a method wait in unity 
Csharp :: bold caption latex 
Csharp :: c# reverse list 
Csharp :: change textbox location C# 
Csharp :: generate random number c# 
Csharp :: unity mouse wheel 
Csharp :: c# counting lines 
Csharp :: double to int c# 
Csharp :: check if string is a guid c# 
Csharp :: unity list of gameobjects 
Csharp :: C# infinite clock coroutine loop 
Csharp :: byte to stream c# 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =