Folow Mouse Position in Unity

In this tutorial, I will add a game object and programming it to follow mouse position every frame.

Ask or Request for anything you want in the comments below 🙂

using UnityEngine;

public class FolowMouse : MonoBehaviour {

   void Update ()
  {
     Vector3 a = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
     a.Set(a.x, a.y, transform.position.z);
     transform.position = Vector3.Lerp(transform.position, a, 1f);
   }
}

FOR MORE