Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FollowMouse.cs
using UnityEngine;
public class FollowMouse : MonoBehaviour
{
public float positionZ = 0;
private void Update()
{
Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mouseWorldPosition.z = positionZ;
transform.position = mouseWorldPosition;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.