Answers for "point at mouse"

C#
5

point at mouse

//Inside your update loop, add the following code:

//First, get the mouse position
Vector2 mousePosition = new Vector2 ( 
  Input.GetAxis("MouseX"), 
  Input.GetAxis("MouseY")
);
//Then, use unity's built-in lookAt function to do all the math for you:
transform.LookAt(mousePosition);
Posted by: Guest on August-19-2020

Code answers related to "point at mouse"

C# Answers by Framework

Browse Popular Code Answers by Language