Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity move object to mouse position

//In 2d/UI you can move the object to your mouse position by writing this in a script and then adding it to the object you want to be at the mouse position also put it in the void update spot
transform.position = Input.mousePosition;

//or in 3d
transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition)
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity object to mouse 
Csharp :: unity change color of sprite in script 
Csharp :: unity3d random 
Csharp :: button action asp net 
Csharp :: newtonsoft json conditionally ignore property 
Csharp :: unity read from text file 
Csharp :: how to draw gizmos unity 
Csharp :: c# keyboard enter 
Csharp :: unity copy list 
Csharp :: conditional blazor styles 
Csharp :: remove last comma from string c# 
Csharp :: c# switch by type of object 
Csharp :: unity round to x decimals 
Csharp :: get length of a string c# 
Csharp :: how to encode and decode a string in c# 
Csharp :: get waht is differnt between two arrays c# 
Csharp :: how to move a gameobject 
Csharp :: unity how to get the first word from string 
Csharp :: get connectionstring from web config c# 
Csharp :: photon rpc 
Csharp :: difference between while and do while in c# 
Csharp :: WebClient c# with custom user agent 
Csharp :: unity deltatime 
Csharp :: How to get an array of months in c# 
Csharp :: convert from xls to xlsx C# 
Csharp :: make window not resizable wpf 
Csharp :: topdown unity 
Csharp :: listview item click c# 
Csharp :: how to clone something unity 
Csharp :: c# ignore enter key 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =